简体   繁体   English

创建类似于iOS 6 App Store按钮的按钮(包含图片)

[英]Create buttons similar to iOS 6 App Store buttons (pic included)

I'm trying to recreate the tableView Apple uses to view the details of an app. 我正在尝试重新创建Apple用于查看应用程序详细信息的tableView。

在此处输入图片说明

I've successfully completed the implementation, except for the shadow inside the buttons. 除了按钮内的阴影,我已经成功完成了实现。 Notice how there is a subtle shadowing effect bordering the details button. 请注意,在“详细信息”按钮的边框处如何产生微妙的阴影效果。

Here is my code that I use to draw the button itself: 这是我用来绘制按钮本身的代码:

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);
}

Here's what it looks like so far: 到目前为止的样子:

在此处输入图片说明

It doesn't look bad, but it's not quit what I'm looking for. 看起来还不错,但是并没有放弃我想要的东西。

Does anyone have any suggestions? 有没有人有什么建议?

You want to apply an inner shadow. 您要应用内部阴影。

Go try this app out http://www.paintcodeapp.com ... it'll write the code for you, it's really handy. http://www.paintcodeapp.com尝试这个程序吧……它将为您编写代码,非常方便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM