2013-05-29 105 views
0

我試圖重新創建AppleView用於查看應用程序的詳細信息的tableView。創建類似於iOS 6 App Store按鈕的按鈕(包括圖片)

enter image description here

我已經成功地完成了實施,除了按鍵內部的影子。注意邊界細節按鈕的細微陰影效果。

這裏是我的代碼,我用它來繪製按鈕本身:

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

這裏是什麼樣子至今:

enter image description here

它看起來並不壞,但它是不放棄我正在尋找的東西。

有沒有人有任何建議?

回答

1

你想申請一個內部的陰影。

去試試這個應用程序http://www.paintcodeapp.com ...它會爲你寫代碼,它真的很方便。

+0

非常感謝您的迴應Mike,這實際上是一些非常酷的軟件。但是我們現在試圖遠離購買任何東西。我會看看試用版能否給我們提供我們想要的。 – pob21

+0

我認爲試用版可以讓你看到它生成的代碼,但不會導出它。你應該足夠了解內部陰影是如何產生和'寫'自己的。 –