Picture separation-split into two pieces

Source: Internet
Author: User

@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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.