IOS 圆角设置
2013-10-30 18:02
218 查看
iOS 系统自带的 View 组件都是正方形的,看起来都太生硬,有时候我需要变成圆角形式,如下图:
具体的实现是使用QuartzCore库,下面我具体的描述一下实现过程:
首先创建一个项目,名字叫:ipad_webwiew
利用Interface Builder添加一个UIWebView,然后和相应的代码相关联
添加QuartzCore.framework
代码实现:
头文件:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@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];
}
具体的实现是使用QuartzCore库,下面我具体的描述一下实现过程:
首先创建一个项目,名字叫:ipad_webwiew
利用Interface Builder添加一个UIWebView,然后和相应的代码相关联
添加QuartzCore.framework
代码实现:
头文件:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@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];
}
相关文章推荐
- iOS 设置自带UISearchBar的背景颜色(并改为圆角)
- <iOS小技巧>UIview指定设置控件圆角
- iOS 分开设置控件四周的四个圆角
- iOS 设置控件圆角及边框
- Ios UIButton 设置圆角和边框
- iOS开发小技巧--设置按钮圆角
- iOS设置圆角的三种方式
- iOS设置圆角矩形和阴影效果
- iOS UITextView 设置圆角边框线
- iOS应用开发中UIView添加边框颜色及设置圆角边框的方法
- 从0开始架构一个IOS程序—— 06—iOS设置圆角图片
- iOS每日一记之———————————————为Cell设置部分圆角 类似于ipad的设置界面效果
- iOS 设置tableView每个分区cell圆角
- iOS 圆角 圆形头像 设置方法
- iOS图片设置圆角性能优化
- iOS开发笔记之设置view部分圆角
- iOS 中如何将View设置为圆角的矩形?
- iOS 图片设置为圆角矩形,圆形等
- iOS 为ImageView设置圆角
- iOS图片圆角设置