[self setNeedsDisplay]&&drawRect几个小点

来源:互联网 发布:张艺谋奥运 知乎 编辑:程序博客网 时间:2024/06/07 22:21
在调用[self setNeedsDisplay]进行重画时

 - (void)drawRect:(CGRect)rect{}


(1)不是立即执行的,会在下一个消息时刻调用drawRect


(2)在执行重画前,画删除之前画的内容


(3)[self.text drawAtPoint:CGPointMake(58withAttributes:attrs];
     [self.text drawInRect:CGRectMake(x, y, w, h) withAttributes:attrs];

     第一个时在指定的位置开始画。第二个是在指定的区域内画,可以自动换行


属性:NSMutableDictionary *attrs = [NSMutableDictionary dictionary];

     attrs[NSFontAttributeName] = self.font;    

     attrs[NSForegroundColorAttributeName] = [UIColor grayColor];

0 0
原创粉丝点击