将视图设置成圆角和阴影添加以及UIButton定义和设置圆角
2015-05-04 15:45
381 查看
</pre><p><strong><span style="font-size:14px">将视图view设置成圆角</span></strong></p><p><pre name="code" class="objc">@interface ipad_webwiewViewController : UIViewController { IBOutlet UIWebView *myWebView; UIView *myView; } @property (nonatomic,retain) UIWebView *myWebView; @end 代码实现: - (void)viewDidLoad { [super viewDidLoad]; // 给图层添加背景图片: //myView.layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage; // 将图层的边框设置为圆脚 myWebView.layer.cornerRadius = 8; myWebView.layer.masksToBounds = YES; // 给图层添加一个有色边框 myWebView.layer.borderWidth = 5; // myWebView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor]; myWebView.layer.borderColor = [[UIColor colorWithRed:231/255.0f green:231/255.0f blue:231/255.0f alpha:1.0f] CGColor]; }
view加阴影
imgView.layer.shadowColor = [UIColor blackColor].CGColor; imgView.layer.shadowOffset = CGSizeMake(0, 0); imgView.layer.shadowOpacity = 0.5; imgView.layer.shadowRadius = 1;
UIButton定义和设置圆角
// .h 中定义 UIButton *_loginBtn; @property (strong,nonatomic)UIButton *loginBtn; // .m 中实现设置按钮 @synthesize loginBtn = _loginBtn;//使用备份变量名 //设置按钮的 形状 self.loginBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; /* buttonWithType: 定义button按钮的外形 六种定义button类型: 下面有图解 UIButtonTypeCustom = 0, 无类型 UIButtonTypeRoundedRect, 四个角是圆弧 型的 UIButtonTypeDetailDisclosure, UIButtonTypeInfoLight, UIButtonTypeInfoDark, UIButtonTypeContactAdd, */ //定义button按钮在frame上的坐标(位置),和这个按钮的宽/高 self.loginBtn.frame = CGRectMake(40, 200, 80, 30); [self.loginBtn setTitle:@"Login" forState:UIControlStateNormal]; /* 常用的属性: setTitle: 设置button按钮的名称 setImage: [UIImage imageNamed:@"图名"] 添加图片 setTitleColor:[UIColor redColor] 设置字体颜色 forState 设置 按钮点击前后的状态 : 下有图解 UIControlStateHighlighted UIControlStateSelected UIControlStateDisabled UIControlStateNormal */ // 为按钮添加一个动作 // action: 如果点击的话执行的方法 [self.loginBtn addTarget:self action:@selector(Login:) forControlEvents:UIControlEventTouchUpInside]; //把button控件添加到view中显示 [self.view addSubview:self.loginBtn];
相关文章推荐
- UIView,UIButton,UIImageView等视图设置圆角,设置阴影,设置边框的方法
- IOS--UIViewUIButtonUIImageView设置圆角、阴影、边框的方法
- 转-UIButton定义和设置圆角
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- IOS成长之路-UIButton定义和设置圆角
- IOS成长之路-UIButton定义和设置圆角
- IOS成长之路-UIButton定义和设置圆角
- UIButton圆角以及边框设置
- UIButton定义和设置圆角
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- 使用js创建div、添加子div并给div设置在css中定义的class选择属性以及设置style属性
- IOS成长之路-UIButton定义和设置圆角
- UIButton定义和设置圆角
- UIButton圆角的设置以及一些系统自定义button
- IOS--UIViewUIButtonUIImageView设置圆角、阴影、边框的方法
- UIButton定义和设置圆角
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- 设置uiview圆角与阴影