UIView加邊框及邊框顏色
引用庫(kù):
#import <QuartzCore/QuartzCore.h>
使用:
//添加邊框和提示
CGRect frameRect = CGRectMake(20, 90, self.window.frame.size.width-40, self.window.frame.size.height-180);
UIView *frameView = [[UIView alloc] initWithFrame:frameRect] ;
frameView.layer.borderWidth = 1;
frameView.layer.borderColor = [[UIColor whiteColor] CGColor];
設(shè)置UIView的邊框?yàn)閳A角
在實(shí)際的應(yīng)用中,總感覺(jué)圓角的東西比較好看, 像button,label,image等等,以前的時(shí)候我就經(jīng)常給那些控件添加一個(gè)UIImageView作為背景,再搞張圓角的圖片,不過(guò)今天發(fā)現(xiàn)了新方法看代碼
viewT.layer.cornerRadius = 10;//設(shè)置那個(gè)圓角的有多圓
viewT.layer.borderWidth = 10;//設(shè)置邊框的寬度,當(dāng)然可以不要
viewT.layer.borderColor = [[UIColor redColor] CGColor];//設(shè)置邊框的顏色
viewT.layer.masksToBounds = YES;//設(shè)為NO去試試
其實(shí)的viewT是UIView的實(shí)例,當(dāng)然也可以是他的子類實(shí)例哈。
最后別忘記添加QuartzCore.framework這個(gè)庫(kù),還有在你的文件中包含#import <QuartzCore/QuartzCore.h>這句哦



















