, - - ... 2 , , , , , .
1: 2 , . . .
2: , () , . , 1 . , UIBezierpath, . . !
:
UIImage *firstImage = [UIImage imageNamed:@"firstImage.png"];
UIImage *secondImage = [UIImage imageNamed:@"secondImage.png"];
self.imageView.image = [self zigZagImageFrom:firstImage secondImage:secondImage];
:
+(UIImage *)zigZagImageFrom:(UIImage *)firstImage secondImage:(UIImage *)secondimage
{
CGFloat width = firstImage.size.width/2;
CGFloat height = firstImage.size.height;
int totalZigzagCurves = 20;
CGFloat zigzagCurveWidth = width/30;
CGFloat zigzagCurveHeight = height/totalZigzagCurves;
CGFloat scale = [[UIScreen mainScreen] scale];
UIGraphicsBeginImageContextWithOptions(firstImage.size, NO, scale);
UIBezierPath *zigzagPath = [[UIBezierPath alloc] init];
[zigzagPath moveToPoint:CGPointMake(0, 0)];
int a=-1;
for (int i=0; i<totalZigzagCurves+2; i++) {
[zigzagPath addLineToPoint:CGPointMake(width+(zigzagCurveWidth*a), zigzagCurveHeight*i + [self randomCurvePoint:i])];
a= a*-1;
}
[zigzagPath addLineToPoint:CGPointMake(0, height)];
[zigzagPath addClip];
[firstImage drawAtPoint:CGPointMake(0, 0)];
UIImage *firstHalfOfImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContextWithOptions(firstImage.size, YES, scale);
[secondimage drawAtPoint:CGPointMake(0, 0)];
[firstHalfOfImage drawAtPoint:CGPointMake(0, 0)];
zigzagPath = [[UIBezierPath alloc] init];
[zigzagPath moveToPoint:CGPointMake(width, -5)];
a=-1;
for (int i=0; i<totalZigzagCurves+2; i++) {
[zigzagPath addLineToPoint:CGPointMake(width+(zigzagCurveWidth*a), zigzagCurveHeight*i + [self randomCurvePoint:i])];
a= a*-1;
}
[[UIColor whiteColor] setStroke];
[zigzagPath setLineWidth:6.0];
[zigzagPath stroke];
UIImage *zigzagImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return zigzagImage;
}
+(int)randomCurvePoint:(int)value{
if (value == 0 || value == 2 ) return -8;
else if (value == 4 || value == 5 || value == 17 || value == 18) return 28;
else if (value == 16 || value == 8 || value == 9 || value == 19) return 2;
else if (value == 12 || value == 13 || value == 14 || value == 15) return -29;
else return 1;
}
:
. , , , 10 , . , .
. :

: UIImage