绘制文字通常分三步走:
①创建字符串对象
②设置字体格式
③通过NSString方法绘制到View中
- //绘制文字
- void drawStr()
- {
- //1.创建绘制文字
- NSString *str = @"I Love Ranran";
- //2.设置字体格式
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- dict[NSForegroundColorAttributeName] = [UIColor redColor];
- dict[NSFontAttributeName] = [UIFont systemFontOfSize:30.0];
- //3.绘制到View中
- [str drawAtPoint:CGPointMake(100 , 100) withAttributes:dict];
- }