2009-12-03 41 views

回答

0

創建您感興趣的圓角矩形圖像。您可以將此圖像添加到不同的用戶界面控件。

3

您創建一個UIView子類,在其中您

#import <QuartzCore/QuartzCore.h> 

及其層的代碼cornerRadius屬性設置到一定量:

self.layer.cornerRadius = 5; 
self.clipsToBounds = YES; 

如果你願意,你可以創建一個屬性你對象,說roundedCornerRadius,並聽取其變化使用KVO,在代碼片段類似於

[self addObserver: self forKeyPath:@"roundedCornerRadius" options:0 context:nil]; 

//implement in your UIView subclass 
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object     
     change:(NSDictionary *)change context:(void *)context 
{ 
    if ([keyPath isEqual: @"roundedCornerRadius"]) 
       self.layer.cornerRadius = roundedCornerRadius; 
} 
0

luvieere的回答爲我工作。

創建一個UIView子類來容納我需要的子視圖來圓角。 (我用IB)。

將該視圖設置爲UIViewController的視圖。

在視圖控制器中重載的viewDidLoad在自定義視圖中調用自定義「viewDidLoad」方法。

這就是我設置需要圓角的子視圖的圓角半徑的地方。

相關問題