@interface viewcontroller ()
@property (nonatomic,strong)Uiimageview *topimageview;
@property(nonatomic,strong)Uiimageview *bottomimageview;
@end
@implementation Viewcontroller
-(void) viewdidload {
[Super viewdidload];
additional setup after loading the view, typically from a nib.
UILabel *label=[[UILabel alloc]initwithframe:cgrectmake( )];
Label. textcolor=[uicolor redcolor];
Label. textalignment=nstextalignmentcenter;
Label. text=@ " you See me " ;
[self. View addsubview: label];
UIImage *imagetop=[UIImage imagenamed:@ "1111.jpg"];
// region clipping based on created image (key code)
cgimageref reftopimg= cgimagecreatewithimageinrect (Imagetop. Cgimagecgrectmake (0 Span class= "S5" >0 Size. Width Size. Height/2
_topimageview=[[uiimageview alloc]initwithframe:cgrectmake(0 , 0, 375, 667/2)];
_topimageview. Image=[UIImage imagewithcgimage: reftopimg];
[self. View addsubview:_topimageview];
cgimageref refbottomimg= cgimagecreatewithimageinrect (Imagetop. Cgimagecgrectmake (0size. Height/2 Size. Width Size. Height/2
_bottomimageview=[[uiimageview alloc]initwithframe:cgrectmake(0 , 667/2, 375, 667/2)];
_bottomimageview. Image=[UIImage imagewithcgimage: refbottomimg];
[self. View addsubview:_bottomimageview];
}
-(void) Touchesbegan: (nsset<uitouch *> *) touches withevent: (uievent *) event
{
[UIView animatewithduration:1 animations: ^{
_topimageview. Frame=cgrectmake(0,-667/2, 375, 667/2);
_bottomimageview. Frame=cgrectmake(0, 667, 375, 667/2);
}];
}
Picture separation-split into two pieces