[英]Create buttons similar to iOS 6 App Store buttons (pic included)
我正在尝试重新创建Apple用于查看应用程序详细信息的tableView。
除了按钮内的阴影,我已经成功完成了实现。 请注意,在“详细信息”按钮的边框处如何产生微妙的阴影效果。
这是我用来绘制按钮本身的代码:
if(self.isSelected) {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, COLORWITHRGB(204, 204, 204).CGColor);
CGContextSetStrokeColorWithColor(context, COLORWITHRGB(141, 141, 141).CGColor);
CGSize labelTextSize = [self.titleLabel.text sizeWithFont: self.titleLabel.font];
CGRect labelFrame = CGRectMake(rect.size.width - labelTextSize.width - 24, (rect.size.height - labelTextSize.height - 4) / 2, labelTextSize.width + 14, labelTextSize.height + 4);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddArc(path, NULL, labelFrame.origin.x + labelFrame.size.width - labelFrame.size.height / 2, labelFrame.origin.y + labelFrame.size.height / 2, labelFrame.size.height / 2, M_PI / 2, M_PI * 3 / 2, YES);
CGPathAddArc(path, NULL, labelFrame.origin.x + labelFrame.size.height / 2, labelFrame.origin.y + labelFrame.size.height / 2, labelFrame.size.height / 2, M_PI * 3 / 2, M_PI / 2, YES);
CGPathAddLineToPoint(path, NULL, labelFrame.origin.x + labelFrame.size.width - labelFrame.size.height / 2, CGRectGetMaxY(labelFrame));
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathFillStroke);
CFRelease(path);
}
到目前为止的样子:
看起来还不错,但是并没有放弃我想要的东西。
有没有人有什么建议?
您要应用内部阴影。
去http://www.paintcodeapp.com尝试这个程序吧……它将为您编写代码,非常方便。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.