美文网首页
Quartz2d--画水印

Quartz2d--画水印

作者: i诺离 | 来源:发表于2017-11-17 09:59 被阅读8次
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        
        UIImage *image = [UIImage imageNamed:@"卡哇伊"];
        
        //生成图片.
        //size:开开启一个多大图片上下文.
        //opaque:不透度
        //scale:0
        //开启跟图片相同的大小上下文.
        UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0);
        //把图片给绘制图片上下文.
        [image drawAtPoint:CGPointZero];
        //绘制文字
        NSString *str = @"小码哥";
        [str drawAtPoint:CGPointZero withAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20]}];
        //生成图片
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        //手动关闭上下文
        UIGraphicsEndImageContext();
    
        self.imageV.image = newImage;
     }
    
    

    相关文章

      网友评论

          本文标题:Quartz2d--画水印

          本文链接:https://www.haomeiwen.com/subject/aokcbttx.html