iOS layer animations

Source: Internet
Author: User


#import "ViewController.h"

@interface Viewcontroller () {
Calayer *_l1;//definition can be used globally
Calayer *_l2;
}

@end

@implementation Viewcontroller

-(void) Viewdidload {
[Super Viewdidload];

Calayer *L2 = [Calayer layer];
L2.frame = CGRectMake (50, 50, 100, 100);
L2.backgroundcolor = [Uicolor Greencolor]. Cgcolor;
L2.transform = Catransform3dmakerotation (M_pi_4, 1, 1, 0);//rotation
[Self.view.layer ADDSUBLAYER:L2];
_L2 = L2;


Calayer *L1 = [Calayer layer];//Create and initialize
L1.frame = CGRectMake (50, 50, 100, 100);
L1.backgroundcolor = [Uicolor Yellowcolor]. cgcolor;//background Color
l1.doublesided = NO; Whether two sides
L1.transform = Catransform3dmakerotation (M_pi_4, 1, 1, 0);//rotation
L1.cornerradius = 30;//When it's a rectangle, this is going to turn into a rounded corner at Four Corners. If there is a picture, the effect is not displayed directly.
L1.maskstobounds = no;//This is when there is a picture will be the extra part of the force cut, you can display the fillet
L1.contents = (__bridge ID) (([UIImage imagenamed:@ "1.jpg"]. Cgimage));//Add a picture
L1.bordercolor = [Uicolor Redcolor]. cgcolor;//Border Color
L1.borderwidth = size of 10;//border
L1.opacity = 1;//Transparency
L1.shadowcolor = [Uicolor blackcolor]. cgcolor;//Shadow Color
L1.shadowopacity = 1;//Shadow Transparency
L1.shadowoffset = Cgsizemake (10, 10);
L1.shadowradius = 6;//radius area size


[Self.view.layer addsublayer:l1];//Show effect on page
_L1 = L1;


}
-(Ibaction) didclicked: (ID) Sender {
_l1.bounds = CGRectMake (0, 0, 100, 100);
_l1.position = cgpointmake (0, 0);//center point to coordinate display
_l1.anchorpoint = Cgpointmake (0, 1);//Anchor Point
_l1.zposition = 100;//above Z axis
_l1.doublesided = no;//Negative None
_l1.transform = Catransform3dmakerotation (m_pi, 1, 0, 0);//rotation
_l2.transform = catransform3didentity;

}
-(Ibaction) DIDCLICKED2: (ID) Sender {
_l2.transform = Catransform3dmakerotation (m_pi, 1, 0, 0);
_l1.transform = catransform3didentity;
}

-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}

@end

iOS layer animations

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.