• ios-水印


    //
    //  ViewController.m
    //  水印
    //
    //  Created by YaguangZhu on 15/9/10.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    @property (weak, nonatomic) IBOutlet UIImageView *imageView;
    
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        UIImage *oldImage = [UIImage imageNamed:@"002"];
        UIGraphicsBeginImageContextWithOptions(oldImage.size, NO, 0.0);
        NSString *text = @"我要高薪 !";
        NSDictionary *dict = @{
                               NSFontAttributeName:[UIFont systemFontOfSize:15],
                               NSForegroundColorAttributeName:[UIColor redColor]
                               };
        [text drawAtPoint:CGPointMake(120, 170) withAttributes:dict];
        
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        
        UIGraphicsEndImageContext();
        
        _imageView.image = newImage;
        
        NSData *data = UIImagePNGRepresentation(newImage);
        
        [data writeToFile:@"/Users/yaguangzhu/Desktop/newimage.png" atomically:YES];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    编写一个C语言程序,产生一个存放26个英文字母组成的线性链表(a,b,c,…,z),并输出该线性表。
    JavaScript之数组函数
    JavaScript之数据类型转化
    xml约束
    PHP初认识
    JavaScript与css3
    JavaScript与css
    HTML5与JavaScript
    JSON
    xml初认识
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4796859.html
Copyright © 2020-2023  润新知