iOS drewRect方法
2015-06-07 20:54
477 查看
You do not need to override this method if your view sets its content in other ways.
By the time this method is called, UIKit has configured the drawing environment appropriately for your view and you can simply call whatever drawing methods and functions you need to render your content. Specifically, UIKit creates and configures a graphics context for drawing and adjusts the transform of that context so that its origin matches the origin of your view’s bounds rectangle. You can get a reference to the graphics context using the UIGraphicsGetCurrentContext function, but do not establish a strong reference to the graphics context because it can change between calls to the drawRect: method.
This method is called when a view is first displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect: method instead.
以上摘自苹果官方文档。
By the time this method is called, UIKit has configured the drawing environment appropriately for your view and you can simply call whatever drawing methods and functions you need to render your content. Specifically, UIKit creates and configures a graphics context for drawing and adjusts the transform of that context so that its origin matches the origin of your view’s bounds rectangle. You can get a reference to the graphics context using the UIGraphicsGetCurrentContext function, but do not establish a strong reference to the graphics context because it can change between calls to the drawRect: method.
This method is called when a view is first displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect: method instead.
以上摘自苹果官方文档。
相关文章推荐
- IOS开发学习笔记043-QQ聊天界面实现
- iOS中的单例
- ios日期格式转换
- QQ聊天界面的布局和设计(IOS篇)-第一季
- IOS 世界标准时间UTC /GMT 转为当前系统时区对应的时间
- iOS中类别的使用
- ios下解决opencv(xcode最新无pch文件的问题)
- iOS开发:设计模式那点事
- 从GetSet看iOS内存机制 (一)
- iOS存储的三种方式
- iOS三级缓存库的实现心得
- iOS_正则表达式
- iOS开发多线程—06线程的状态
- iOS开发多线程—05GCD介绍
- iOS开发多线程—04线程间的通信
- iOS开发多线程—03线程安全
- iOS开发多线程—01多线程简单介绍
- iOS开发多线程—02创建线程
- [转]iOS 不要使用tag传递TableViewCell的indexPath值
- iOS CoreData详解(七)性能相关