iOS开发:触摸事件处理与表格视图设计
1. 视图绘制
在iOS开发中,绘制视图的方式与常规认知有所不同。并非在事件发生时立即绘制,而是记录需要绘制的内容,等待iOS通知对象进行绘制,绘制由用户界面更新事件触发。当iOS要求视图自行绘制时,对象会收到 -drawRect: 消息。以下是添加到实现中的 -drawRect: 方法示例:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(context,rect);
UIBezierPath *path = nil;
if (touchPoints.count>1)
{
path = [UIBezierPath bezierPath];
NSValue* firstLocation = nil;
for ( NSValue *location in touchPoints )
{
if (firstLocation==nil)
{
firstLocation = location;
[path moveToPoint:location.CGPointValue];
}
超级会员免费看
订阅专栏 解锁全文
66

被折叠的 条评论
为什么被折叠?



