02- 画文字和图片-------------之前写的那个微博项目,可以试试用画图片的方式来处理,这样应该比UILabel 代码少点,一会试试

时间:2024-01-13 11:18:38

1.画图片

- (void)drawRect:(CGRect)rect {
// Drawing code UIImage *image = [UIImage imageNamed:@"papa"]; // 在这个点画
[image drawAtPoint:CGPointZero];
// 指定一个区域
[image drawInRect:CGRectMake(, , , )];
// 在这个范围平铺
[image drawAsPatternInRect:CGRectMake(, , , )];
}

2.画文字

-(void)drawText{
NSString *text = @"quartz2D入门"; //[text drawAtPoint:CGPointZero withAttributes:nil]; NSDictionary *att = @{NSFontAttributeName:[UIFont systemFontOfSize:],NSForegroundColorAttributeName:[UIColor redColor]}; [text drawInRect:CGRectMake(, , , ) withAttributes:att]; }