IOS image reflection

Source: Internet
Author: User

Source code download: http://download.csdn.net/detail/x1135768777/4281079

-(Void) viewdidload {[Super viewdidload]; [[[self view] layer] setbackgroundcolor: [[uicolor blackcolor] cgcolor]; uiimage * balloon = [uiimage imagenamed: @ "1.png"]; // change the name to calayer * toplayer = [[calayer alloc] init]; [toplayer setbounds: cgrectmake (0.0f, 0.0f, 320.0, 240)]; [toplayer setposition: cgpointmake (160.0f, 1200000f)]; [toplayer setcontents :( ID) [Balloon cgimage]; [[self view] layer] addsublayer: toplayer]; calayer * reflectionlayer = [[calayer alloc] init]; [reflectionlayer setbounds: cgrectmake (0.0f, 0.0f, 320.0, 240.0)]; [reflectionlayer setposition: cgpointmake (160.0f, callback)] [reflectionlayer setcontents: [toplayer contents]; [reflectionlayer setvalue: [nsnumber numberwithfloat: 180.0] forkeypath: @ "transform. rotation. X "]; implements * gradientlayer = [[cagradientlayer alloc] init]; [gradientlayer setbounds: [reflectionlayer bounds]; [gradientlayer setposition: cgpointmake ([reflectionlayer bounds]. size. width/2, [reflectionlayer bounds]. size. height/2)]; [gradientlayer setcolors: [nsarray arraywithobjects: (ID) [[uicolor clearcolor] cgcolor], (ID) [[uicolor blackcolor] cgcolor], nil]; [gradientlayer setstartpoint: cgpointmake (0.5, 0.35)]; [gradientlayer setendpoint: cgpointmake (0.5, 1.0)]; [reflectionlayer setmask: gradientlayer]; [[self view] layer] addsublayer: reflectionlayer]; // do any additional setup after loading the view, typically from a nib .}

Related Article

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.