UIView加边框及边框颜色
引用库:
复制代码 代码如下:
复制代码
#import <QuartzCore/QuartzCore.h>
#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];
//添加边框和提示
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];
设置UIView的边框为圆角
在实际的应用中,总感觉圆角的东西比较好看, 像button,label,image等等,以前的时候我就经常给那些控件添加一个UIImageView作为背景,再搞张圆角的图片,不过今天发现了新方法看代码
复制代码 代码如下:
复制代码
viewT.layer.cornerRadius = 10;//设置那个圆角的有多圆
viewT.layer.borderWidth = 10;//设置边框的宽度,当然可以不要
viewT.layer.borderColor = [[UIColor redColor] CGColor];//设置边框的颜色
viewT.layer.masksToBounds = YES;//设为NO去试试
viewT.layer.cornerRadius = 10;//设置那个圆角的有多圆
viewT.layer.borderWidth = 10;//设置边框的宽度,当然可以不要
viewT.layer.borderColor = [[UIColor redColor] CGColor];//设置边框的颜色
viewT.layer.masksToBounds = YES;//设为NO去试试
其实的viewT是UIView的实例,当然也可以是他的子类实例哈。
最后别忘记添加QuartzCore.framework这个库,还有在你的文件中包含#import <QuartzCore/QuartzCore.h>这句哦
最后
以上就是忧伤魔镜最近收集整理的关于iOS应用开发中UIView添加边框颜色及设置圆角边框的方法的全部内容,更多相关iOS应用开发中UIView添加边框颜色及设置圆角边框内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复