iOS-裁剪图片

来源:互联网 发布:次新人工智能概念股 编辑:程序博客网 时间:2024/05/22 17:09


//裁剪图片(UIImage是点坐标 CGImage是像素坐标)

    //加载大图片

    UIImage *bigImage = [UIImageimageNamed:@“icon”];


//从大图片中裁剪出对应小图片

    //屏幕的伸缩属性

CGFloat num = 10

    CGFloat scale = [UIScreenmainScreen].scale;

    CGFloat smallW = bigImage.size.width/10 * scale;

    CGFloat smallH = bigImage.size.height * scale;


for (int index =0; index < num; index++) {

    

        CGRect smallRect =CGRectMake(index * smallW,0, smallW, smallH);

        //CGImageCreateWithImageInRect只认像素

        CGImageRef smallImage = CGImageCreateWithImageInRect(bigImage.CGImage, smallRect);


UIImage *lastImage = [UIImageimageWithCGImage:smallImage];

        

}

0 0
原创粉丝点击