Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <QuartzCore/QuartzCore.h>
- // create a perfect circle view
- - (UIView*)createCircleViewWithRadius:(int)radius
- {
- // circle view
- UIView *circle = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 2 * radius, 2 * radius)] autorelease];
- circle.layer.cornerRadius = radius;
- circle.layer.masksToBounds = YES;
- // border
- circle.layer.borderColor = [UIColor whiteColor].CGColor;
- circle.layer.borderWidth = 1;
- // gradient background color
- CAGradientLayer *gradientBg = [CAGradientLayer layer];
- gradientBg.frame = circle.frame;
- gradientBg.colors = [NSArray arrayWithObjects:
- (id)[UIColor redColor].CGColor,
- (id)[UIColor blackColor].CGColor,
- nil];
- // vertical gradient
- gradientBg.locations = [NSArray arrayWithObjects:
- [NSNumber numberWithFloat:0.0f],
- [NSNumber numberWithFloat:1.0f],
- nil];
- // gradient background
- CALayer *layer = circle.layer;
- layer.masksToBounds = YES;
- [layer insertSublayer:gradientBg atIndex:0];
- return circle;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement