添加一个UIView时,默认直角显示有时对于有强迫症的患者还真有点不舒服!

eg:

iOS -实现UIView圆角显示的方法-LMLPHP

怎么实现UIview的圆角显示呢?

首先包含一个头文件:

#import <QuartzCore/QuartzCore.h>

其次设置两个属性:

    self.userView.layer.cornerRadius = 2;
self.userView.layer.masksToBounds = YES;

eg:

-(void)setupUI {
//set subview round corners
self.userView.layer.cornerRadius = 2;
self.userView.layer.masksToBounds = YES;
//set backgroundColor
[self.userView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"textField_normal"]]];
self.userNameButton.enabled = NO; self.passwordView.layer.cornerRadius = 2;
self.passwordView.layer.masksToBounds = YES;
[self.passwordView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"textField_normal"]]];
self.passwordButton.enabled = NO; }
</pre><pre name="code" class="objc">显示效果:
</pre><pre name="code" class="objc"></pre><pre name="code" class="objc" style="color: rgb(209, 47, 27);">

iOS -实现UIView圆角显示的方法-LMLPHP

05-11 14:47