UIView中的drawRect
来源:互联网 发布:v meca mt2软件 编辑:程序博客网 时间:2024/06/10 09:51
想要重绘的话,仅仅创建一个UIView的父类并且重载drawRect
override func drawRect(regionThatNeedsToBeDrawn: CGRect)
你可以在外面画一个需要重绘的区域,但是他不是最优化的。
永远不要调用drawRect!!
setNeedsDisplay()
setNeedsDisplayInRect(regionThatNeedsToBeRedrawn:CGRect)
IOS之后会在恰当的时间调用deawRect
Core Graphics Concepts
Create a UIBezierPath,画三角形
let path = UIBezierPath()
Move around, add lines or arcs to the path
path.moveToPoint(CGPoint(80,50)) // assume screen is 160x250
path.addLineToPoint(CGPoint(140,150))
path.addLineToPoint(CGPoint(10,150))
Close the path (if you want)
path.closePath()
Now that you have a path, set attributes and stroke/fill
// note this is a method in UIColor, not UIBezierPath
UIColor.greenColor().setFill()
// note this is a method in UIColor, not UIBezierPath
UIColor.redColor().setStroke()
// note this is a property in UIBezierPath, not UIColor
path.linewidth =3.0
path.fill()
path.stroke()
//用UIBezierPath画圆
let roundRect =UIBezierPath(roundedRect: aCGRect, cornerRadius: aCGFloat)
//用UIBezierPath画椭圆
let oval =UIBezierPath(ovalInRect: aCGRect)
//画圆角
addClip()
- UIView中的drawRect方法
- UIView中的drawRect
- UIView中的layoutSubviews和drawRect
- UIView中的layoutSubviews和drawRect
- UIView DrawRect中的坐标转换基础
- Objective-C 与Swift - UIView中的- (void)drawRect:(CGRect)rect
- UIView drawRect函数
- UIView的drawRect
- UIView drawRect函数
- 关于UIView drawRect方法
- UIView的drawRect方法
- UIView的drawRect方法
- UIView之drawRect
- UIView的layoutSubviews和drawRect
- UIView的layoutSubviews和drawRect
- UIView重绘机制drawRect
- UIView的layoutSubviews和drawRect
- UIView的layoutSubviews和drawRect
- DirectX中的基本数学知识
- maven+spring+springMVC+mybatis环境搭建
- 扩展欧几里得应用分析
- Android 系统中 Location Service 的实现与架构
- 解决sublimeText3无法安装插件问题 -- There are no packages available for installation
- UIView中的drawRect
- opoengl 投影矩阵的推导
- HDFS NFS Gateway使用
- 8位灰度图二维卷积高斯模糊(VC++)
- HTTP-http简介
- 《Java编程思想》学习笔记5——正则表达式量词匹配
- Android自定义组合标题控件
- 如何为.NET MVC添加Azure AD验证
- oracle 普通表变更分区表的数据迁移