2012-08-23 40 views

回答

1

設置視圖的角Radius並在其下面插入標籤。

iPhone支持CALayer類的cornerRadius屬性。每個視圖都有一個可以操作的CALayer實例。

所有#import <QuartzCore/QuartzCore.h>並鏈接到QuartzCore framework首先以訪問的CALayer的頭和properties.Then,

yourView.layer.cornerRadius = 8; 
+0

我們如何設置th e角半徑?如果你有空閒時間,你能舉個例子嗎?感謝Advances。 – Sovannarith

+0

我已經添加了代碼。它只是一行代碼,你需要包含一個使用它的框架 –

+0

現在它可以工作。非常感謝你。 – Sovannarith

1

您可以通過

yourview.layer.cornerRadius = 8.0; // or other value 
2

使用此代碼,使圓邊

UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [bt setFrame:CGRectMake(10, 10, 50, 50)]; 
    [bt setImage:[UIImage imageNamed:@"abc.png" ] forState:UIControlStateNormal]; 

    // Get the Layer of any view 
    CALayer * l = [bt layer]; 
    [l setMasksToBounds:YES]; 
    [l setCornerRadius:10.0]; 

    // You can even add a border 
    [l setBorderWidth:4.0]; 
    [l setBorderColor:[[UIColor blueColor] CGColor]]; 
    [self.view addSubview:bt];