zoukankan      html  css  js  c++  java
  • ios 裁剪图片(1裁多)

    裁剪图片:(C类库方法)

    - (void)viewDidLoad {
        [super viewDidLoad];
        UIImageView *iv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 60, 90)];
        [self.view addSubview:iv];
        
        //得到僵尸的完整图片
        UIImage *zombImage = [UIImage imageNamed:@"zomb_2"];
    
    //    ************截取单张图片
    //    截取里面的图片 CG开头
        CGImageRef subImage = CGImageCreateWithImageInRect(zombImage.CGImage, CGRectMake(0, 0, zombImage.size.width/8, zombImage.size.height));
    
    //    把CGImage转成 UIImage
        iv.image = [UIImage imageWithCGImage:subImage];
    
    
        //释放用完的CG图片
           CGImageRelease(subImage);
    
    //   *******************截取每一张
        NSMutableArray *images = [NSMutableArray array];
    
    //    0w 1w  2w  3w
        for (int i=0; i<8; i++) {
            CGImageRef imageRef = CGImageCreateWithImageInRect(zombImage.CGImage, CGRectMake(i*(zombImage.size.width/8), 0, zombImage.size.width/8, zombImage.size.height));
            [images addObject:[UIImage imageWithCGImage:imageRef]];
    
            //把用完的imageRef释放(CG...框架没有自动释放池,需要手动释放)
            CGImageRelease(imageRef);
        }
        //设置动画的代码
        [iv setAnimationImages:images];
        [iv setAnimationDuration:1];
        [iv setAnimationRepeatCount:0];
        [iv startAnimating];
        
    }
    
    成功的三大原则: 1、坚持 2、不要脸 3、坚持不要脸
  • 相关阅读:
    字符,字符串,字节
    111
    串口通信
    字符编码
    枚举和结构体
    参数数组
    .Net垃圾回收机制
    try{ } catch{ } finally{ }
    LVS 工作原理图文讲解
    自动化运维工具—Ansible常用模块二
  • 原文地址:https://www.cnblogs.com/xulinmei/p/7420297.html
Copyright © 2011-2022 走看看