ckteebe / CustomBadge

CustomBadge is an Objective-C based component to create customized Badges for any given View.
http://saschapaulus.de/opensource
MIT License
397 stars 132 forks source link

add iOS 7 style #9

Closed chrischenyc closed 10 years ago

chrischenyc commented 11 years ago

can you add a solid colored style, like iOS 7 does...

cja1 commented 11 years ago

Hi,

This is pretty easy to tweak with the existing code. In summary you need to switch off the Shine, switch off the Frame and switch off the Shadow. Then it looks like IOS7 as far as I can see.

What I did:

Added this code to .m file:

+ (CustomBadge*) customBadgeIOS7WithString:(NSString *)badgeString withScale:(CGFloat)scale {
    return [[[self alloc] initWithString:badgeString withStringColor:[UIColor whiteColor] withInsetColor:[UIColor redColor] withBadgeFrame:NO withBadgeFrameColor:nil withScale:scale withShining:NO] autorelease];
}

This takes care of the first two items: Shine and Frame. To stop the Shadow just comment out this line in drawRoundedRectWithContext:

CGContextSetShadowWithColor(context, CGSizeMake(1.0,1.0), 3, [[UIColor blackColor] CGColor]);
ckteebe commented 10 years ago

The new version supports both: Prior iOS7 style and iOS7 or higher style.