|
//// General Declarations |
|
CGContextRef context = UIGraphicsGetCurrentContext(); |
|
//// Color Declarations |
|
UIColor *color = [UIColor colorWithRed:0.306 green:0.678 blue:0.604 alpha:1.0]; |
|
UIColor *shadowColor = [UIColor colorWithRed:0.20 green:0.200 blue:0.200 alpha:1.0]; |
|
|
|
NSShadow *shadow; |
|
shadow.shadowColor = [shadowColor colorWithAlphaComponent:0.72]; |
|
shadow.shadowOffset = CGSizeMake(0.1, -0.1); |
|
shadow.shadowBlurRadius = 5; |
|
|
|
//// Rectangle Drawing |
|
CGRect rectangleRect = CGRectMake(52, 35, 140, 37); |
|
UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRoundedRect:rectangleRect cornerRadius:15]; |
|
CGContextSaveGState(context); |
|
|
|
CGContextSetShadowWithColor(context, shadow.shadowOffset, shadow.shadowBlurRadius, shadowColor.CGColor); |
|
[color setFill]; |
|
[rectanglePath fill]; |
|
CGContextRestoreGState(context); |
|
|
|
NSString *rectangleTextContent = @"Take a picture"; |
|
NSMutableParagraphStyle *rectangleStyle = (NSMutableParagraphStyle *)[[NSParagraphStyle defaultParagraphStyle]mutableCopy]; |
|
rectangleStyle.alignment=NSTextAlignmentCenter; |
|
|
|
NSDictionary *rectangleFontAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: [UIFont fontWithName:@"Range-SemiBold" size:15], NSFontAttributeName, [UIColor whiteColor], rectangleStyle, nil]; |
|
CGFloat rectangleTextHeight = ([rectangleTextContent boundingRectWithSize:CGSizeMake(rectangleRect.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:rectangleFontAttributes context:nil]).size.height; |
|
CGContextSaveGState(context); |
|
|
|
CGContextClipToRect(context, rectangleRect); |
|
[rectangleTextContent drawInRect:CGRectMake(rectangleRect.origin.x, rectangleRect.origin.y + (rectangleRect.size.height - rectangleTextHeight) / 2, rectangleRect.size.width, rectangleTextHeight) withAttributes:rectangleFontAttributes]; |
|
CGContextRestoreGState(context); |