最近的需求中有个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设置少于四个的圆角的更多相关文章

  1. iOS UIView设置圆角

    UIView设置圆角 1.比较简单的情况,UIView四个角都是圆角: UIView *aView = [[UIView alloc] init]; aView.frame = CGRectMake( ...

  2. Swift - 设置tableView每个分区cell圆角

    1.// 重新绘制cell边框 func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRow ...

  3. UIView设置背景渐变色

    UIView设置背景渐变色 // Allocate bitmap context CGContextRef bitmapContext = CGBitmapContextCreate(NULL, , ...

  4. {Django基础七之Ajax} 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解)

    Django基础七之Ajax 本节目录 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解) 一 Ajax简介 ...

  5. swift关于UIView设置frame值的extension

    swift关于UIView设置frame值的extension 使用 说明 1. 使用如上图,很简单,不再赘述 2. 在extension给添加的计算属性提供getter,setter方法即可 源码 ...

  6. 把Notepad++的tab设置为四个空格

    在7.1版本以及以后 设置->首选项->Language 勾选Repalce by space 在7.1版本以前 设置->首选项->制表符设置 右侧,转为空格,勾选上 参考: ...

  7. {Django基础七之Ajax} 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解)

    {Django基础七之Ajax} 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解)   Django基础七之 ...

  8. iOS 通过storyboard设置UIView或者其他layer图层的圆角

    通常我们给Button或者UIView添加圆角是通过如下代码进行实现的 self.button.layer.cornerRadius=10; 但是如果你是使用的故事版或者xib进行设计视图的话,实际上 ...

  9. UIView 设置背景图片

    http://blog.csdn.net/qijianli/article/details/7777268 项目中,可能需要我们为某个视图设置背景图片,而API中UIView没有设置背景图片的方法,那 ...

随机推荐

  1. easyui之datagrid(不定时补充)

    1,datagrid之formatter formatter格式化函数有三个参数: value:字段值(一般为后台传递给前台的值): row:当前行数据: index:当前行索引. return值是显 ...

  2. CentOS 5.5安装图解教程

    说明:实际生产环境中,CentOS 5.5这个版本相当稳定,而且硬件兼容性也很好,是很多服务器装机者的首选系统,下面介绍CentOS 5.5的具体安装过程   说明:实际生产环境中,CentOS 5. ...

  3. OOAD基本概念

    学习目标: 1.理解与掌握面向对象的概念与方法. 2.使用UML. 3.完成面向对象的分析与设计工作. 4.了解OO的设计原则及一些典型的设计模式 什么是面向对象? 面向对象(Object-Orien ...

  4. 项目中redis类似MVC的使用

  5. php目录分隔符DIRECTORY_SEPARATOR

    在windows我们习惯性的使用“\”作为文件分隔符,但是在linux上系统不认识这个标识,于是就要引入这个php内置变量了:DIRECTORY_SEPARATOR 路径分隔符 windows \ o ...

  6. BufferedInputStream

    package file; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStrea ...

  7. IIC 概述之24c系列存储器内存分析

    IIC 型号     容量      器件/业面寻址字节                   可寻址位       模块 24C01   128B      (1010)(A2)(A1)(A0)(0或 ...

  8. TF.Learn

    TF.Learn 手写文字识别   转载请注明作者:梦里风林Google Machine Learning Recipes 7官方中文博客 - 视频地址Github工程地址 https://githu ...

  9. NSNotificationCenter基础知识

    NSNotificationCenter基础知识   Notification的工作机制 1.对应用程序中其他地方发生的事件(比如增加一条数据库记录)感兴趣的对象,会向通告中心(Notificatio ...

  10. iOS 拨打电话三种方式总结

    1,这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示NSMutableString * str=[[NSMutableString alloc] initWithFo ...