iOS App的切图

2016-08-16  本文已影响65人  不吃鸡爪

切图中需要注意的几点
1.可重复元素:当背景图是可重复的纹理图案时

元素
UIColor *circleColorPattern = [UIColor colorWithPatternImage:
                               [UIImage imageNamed:@"love"]];

可以得到一个颜色模板,用这个颜色画或者填充某个区域的时候,模板图片会在指定的区域内平铺,如

纹理图案

2.某个图片从中间拉伸

UIImage *raImg = [UIImage imageNamed:@"SenderTextNodeBkg"];
int raW = raImg.size.width/2;
int raH = raImg.size.height/2;
[raImg resizableImageWithCapInsets:UIEdgeInsetsMake(raH, raW, raH, raW) resizingMode:UIImageResizingModeStretch];

UIImageView *raImgv = [[UIImageView alloc]initWithImage:raImg];
raImgv.frame = CGRectMake(10, 100, 200, 300);
[self.view addSubview:raImgv];

用于mask遮罩效果的图片配合resizableImage使用

遮罩.gif
//背景图
UIImage *img = [UIImage imageNamed:@"bj.jpg"];
UIImageView *imgv = [[UIImageView alloc]initWithImage:img];
imgv.frame = CGRectMake(0, 0, imgv.frame.size.width/3, imgv.frame.size.height/3);
imgv.center = self.view.center;
[self.view addSubview:imgv];

//mask Image
UIImage *maskImg = [UIImage imageNamed:@"mb"];
int wM = maskImg.size.width/2;
int hM = maskImg.size.height/2;
[maskImg resizableImageWithCapInsets:UIEdgeInsetsMake(hM, wM, hM, wM) resizingMode:UIImageResizingModeStretch];

// mask ImageView
UIImageView *maskImgv = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
maskImgv.image = maskImg;
imgv.maskView = maskImgv;

// animation
[UIImageView animateWithDuration:3.0f animations:^{
    maskImgv.frame = imgv.bounds;
}];
上一篇 下一篇

猜你喜欢

热点阅读