Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate

.DS_Store
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
Expand Down
4 changes: 3 additions & 1 deletion JBWatchActivityIndicator/JBWatchActivityIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ typedef NS_ENUM(NSInteger, JBWatchActivityIndicatorType) {
JBWatchActivityIndicatorTypeRingLarge,
JBWatchActivityIndicatorTypeSegments,
JBWatchActivityIndicatorTypeSegmentsSmall,
JBWatchActivityIndicatorTypeSegmentsLarge
JBWatchActivityIndicatorTypeSegmentsLarge,
JBWatchActivityIndicatorTypeRingDevide
};

typedef NS_ENUM(NSInteger, JBWatchActivityIndicatorSegmentStyle) {
Expand All @@ -63,6 +64,7 @@ typedef NS_ENUM(NSInteger, JBWatchActivityIndicatorSegmentStyle) {
@property (nonatomic, readwrite, assign) CGFloat darkestAlpha;
@property (nonatomic, readwrite, assign) CGFloat numberOfFrames;
@property (nonatomic, readwrite, assign) CGFloat indicatorScale;
@property (nonatomic, readwrite, assign) BOOL isDevideMode;

- (instancetype)initWithType:(JBWatchActivityIndicatorType)type NS_DESIGNATED_INITIALIZER;

Expand Down
20 changes: 18 additions & 2 deletions JBWatchActivityIndicator/JBWatchActivityIndicator.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ - (instancetype)initWithType:(JBWatchActivityIndicatorType)type {
_brightestAlpha = (254.0f / 255.0f);
_darkestAlpha = (57.0f / 255.0f);
_numberOfFrames = 15;

_isDevideMode = NO;

switch (type) {

case JBWatchActivityIndicatorTypeDefault:
Expand All @@ -78,6 +79,9 @@ - (instancetype)initWithType:(JBWatchActivityIndicatorType)type {
(type == JBWatchActivityIndicatorTypeDotsSmall ? 0.5f : 2.0f));
break;
}
case JBWatchActivityIndicatorTypeRingDevide:
_isDevideMode = YES;

case JBWatchActivityIndicatorTypeRing:
case JBWatchActivityIndicatorTypeRingSmall:
case JBWatchActivityIndicatorTypeRingLarge: {
Expand Down Expand Up @@ -153,8 +157,9 @@ - (UIImage *)imageForFrameAtIndex:(NSUInteger)frameIndex {

for (NSUInteger segmentIndex = 0; segmentIndex < self.numberOfSegments; segmentIndex++) {

CGFloat alphaAngle = (((CGFloat)(self.numberOfSegments - segmentIndex) / (CGFloat)self.numberOfSegments) * PI2);
CGFloat alphaAngle = (((CGFloat)(self.numberOfSegments - [self alphaIndex:segmentIndex]) / (CGFloat)self.numberOfSegments) * PI2);
CGFloat alpha = alphaAxis + (sinf(frameAngle + alphaAngle) * semiAmplitude);
alpha = 1-alpha;

if (self.segmentStyle == JBWatchActivityIndicatorSegmentStyleCircle) {

Expand Down Expand Up @@ -195,4 +200,15 @@ - (UIImage *)imageForFrameAtIndex:(NSUInteger)frameIndex {
return image;
}

- (NSUInteger)alphaIndex:(NSUInteger)segmentIndex
{
NSUInteger alphaIndex = segmentIndex;
if (_isDevideMode){
if (alphaIndex > self.numberOfSegments/2-1){
alphaIndex -= self.numberOfSegments/2-1;
}
}
return alphaIndex;
}

@end
5 changes: 3 additions & 2 deletions JBWatchActivityIndicator/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ - (void)viewDidLoad {
[super viewDidLoad];

self.totalImageBytesLabel.text = @"";

[self applyType:JBWatchActivityIndicatorTypeDefault];

//[self applyType:JBWatchActivityIndicatorTypeDefault];
[self applyType:JBWatchActivityIndicatorTypeRingDevide];
}

- (void)applyType:(JBWatchActivityIndicatorType)type {
Expand Down