【发布时间】:2016-04-01 11:19:22
【问题描述】:
如何为 UI 导航创建自定义后退按钮
这是我目前的代码
我是 xcode 开发的新手
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* color = [UIColor colorWithRed: 0.8 green: 0.32 blue: 0.32 alpha: 1];
//// Rectangle Drawing
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(18, 104, 263, 93) cornerRadius: 5];
[color setFill];
[rectanglePath fill];
//// Text Drawing
CGRect textRect = CGRectMake(47, 123, 205, 55);
{
NSString* textContent = @"Back";
NSMutableParagraphStyle* textStyle = NSMutableParagraphStyle.defaultParagraphStyle.mutableCopy;
textStyle.alignment = NSTextAlignmentCenter;
NSDictionary* textFontAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize: 30], NSForegroundColorAttributeName: UIColor.blackColor, NSParagraphStyleAttributeName: textStyle};
CGFloat textTextHeight = [textContent boundingRectWithSize: CGSizeMake(textRect.size.width, INFINITY) options: NSStringDrawingUsesLineFragmentOrigin attributes: textFontAttributes context: nil].size.height;
CGContextSaveGState(context);
CGContextClipToRect(context, textRect);
[textContent drawInRect: CGRectMake(CGRectGetMinX(textRect), CGRectGetMinY(textRect) + (CGRectGetHeight(textRect) - textTextHeight) / 2, CGRectGetWidth(textRect), textTextHeight) withAttributes: textFontAttributes];
CGContextRestoreGState(context);
}
【问题讨论】:
标签: ios objective-c button ios7 uikit