UIView设置少于四个的圆角
最近的需求中有个label需要设置右下角为圆角,其余三个为直角,一开始用的是重写drawRect,然后用绘图重绘每个角的样子,计算起来还是麻烦
后来发现了下面的方法:
UILabel *courseStyleLabel = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
courseStyleLabel.backgroundColor = CreateColorByRGB(TitleBgImgViewColor);
courseStyleLabel.textColor = [UIColor whiteColor];
courseStyleLabel.textAlignment = NSTextAlignmentCenter;
courseStyleLabel.font = [UIFont systemFontOfSize:12.0];
courseStyleLabel.layer.masksToBounds = YES; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:courseStyleLabel.bounds
byRoundingCorners:UIRectCornerBottomRight
cornerRadii:CGSizeMake(, )];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = courseStyleLabel.bounds;
maskLayer.path = maskPath.CGPath;
courseStyleLabel.layer.mask = maskLayer;
[courseImage addSubview:courseStyleLabel];
显示效果是右下角有个 弧度为 3 的小圆角
UIRectCornerTopLeft = << ,
UIRectCornerTopRight = << ,
UIRectCornerBottomLeft = << ,
UIRectCornerBottomRight = << ,
UIRectCornerAllCorners = ~0UL
通过这个枚举值判断画哪个圆角
UIView设置少于四个的圆角的更多相关文章
- iOS UIView设置圆角
UIView设置圆角 1.比较简单的情况,UIView四个角都是圆角: UIView *aView = [[UIView alloc] init]; aView.frame = CGRectMake( ...
- Swift - 设置tableView每个分区cell圆角
1.// 重新绘制cell边框 func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRow ...
- UIView设置背景渐变色
UIView设置背景渐变色 // Allocate bitmap context CGContextRef bitmapContext = CGBitmapContextCreate(NULL, , ...
- {Django基础七之Ajax} 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解)
Django基础七之Ajax 本节目录 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解) 一 Ajax简介 ...
- swift关于UIView设置frame值的extension
swift关于UIView设置frame值的extension 使用 说明 1. 使用如上图,很简单,不再赘述 2. 在extension给添加的计算属性提供getter,setter方法即可 源码 ...
- 把Notepad++的tab设置为四个空格
在7.1版本以及以后 设置->首选项->Language 勾选Repalce by space 在7.1版本以前 设置->首选项->制表符设置 右侧,转为空格,勾选上 参考: ...
- {Django基础七之Ajax} 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解)
{Django基础七之Ajax} 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解) Django基础七之 ...
- iOS 通过storyboard设置UIView或者其他layer图层的圆角
通常我们给Button或者UIView添加圆角是通过如下代码进行实现的 self.button.layer.cornerRadius=10; 但是如果你是使用的故事版或者xib进行设计视图的话,实际上 ...
- UIView 设置背景图片
http://blog.csdn.net/qijianli/article/details/7777268 项目中,可能需要我们为某个视图设置背景图片,而API中UIView没有设置背景图片的方法,那 ...
随机推荐
- traditional:true
- Java系列--第四篇 基于Maven的SSME之发送邮件
在系列第一篇中,使用的是mybatis得到了一个小小的项目,而该项目的用户对象是有邮件地址的,如果按照邮件地址给对方去一封邮件会不会更能体现针对性呢,所以,我在这篇准备加入发送邮件的功能,利用的就是s ...
- dede轮播图
DEDEcms 里面有个自带的轮播图调用: 模版 ------> 广告管理 --------> 增加一个新广告 ----进入后的界面 填写后 点击 代码获取相应的JS调用代码:或者织梦CM ...
- windows下配置lamp环境(2)---配置Apache服务器2.2.25
配置Apache 配置Apache时,先要找到安装目录中的主配置文httpd.conf,使用文本编辑器打开,最好不要使用windows自带的编辑器,可以使用NotePad++, vim,或者subli ...
- QM项目开发文档整理
QM项目开发文档整理 前言 在W公司工作4个多月,庆幸接触到的全是"硬"项目,真枪实干,技术.经验.能力都得到了很大提升. QM项目 此项目WEB前端学到的东西很多,对PHP项目的 ...
- Android热补丁动态修复
1.前言 由于公司项目中使用到热修复技术,之前对这块技术知之甚少,所以有时间去学习了解了一下. 2.学习资源 2.1 热修复介绍 还是鸿洋老师的精彩讲解,中间引用了Andorid dex分包方案和QQ ...
- Lintcode--005(最长公共子序列)
Given two strings, find the longest common subsequence (LCS). 最长公共子序列 Your code should return th ...
- commons-pool2-中的一些配置
/** * 连接失效检测相关 */ // 空闲时进行连接测试,会启动异步evi ...
- cf Ping-Pong (Easy Version)
http://codeforces.com/contest/320/problem/B 这道题看了很长时间没看懂, 就是个dfs: #include <cstdio> #include & ...
- ASP.ENT中上一篇和下一篇
前台页面:<div class="mtgz_prev_next"> <p> <span class="textcolor ...