02- 画文字和图片-------------之前写的那个微博项目,可以试试用画图片的方式来处理,这样应该比UILabel 代码少点,一会试试
1.画图片
- (void)drawRect:(CGRect)rect { // Drawing code UIImage *image = [UIImage imageNamed:@"papa"]; // 在这个点画 [image drawAtPoint:CGPointZero]; // 指定一个区域 [image drawInRect:CGRectMake(10, 10, 50, 50)]; // 在这个范围平铺 [image drawAsPatternInRect:CGRectMake(0, 0, 200, 200)]; }
2.画文字
-(void)drawText{ NSString *text = @"quartz2D入门"; //[text drawAtPoint:CGPointZero withAttributes:nil]; NSDictionary *att = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor redColor]}; [text drawInRect:CGRectMake(10, 10, 120, 44) withAttributes:att]; }