Simple gradient drawing for iOS

Source: Internet
Author: User

The first few weeks of the music list in the project to add a shadow to the left to make a smooth effect.

With a very simple gradient implementation:

The code is as follows:

1-(Cagradientlayer *) Shadowofmusic: (float) frameheight 2 {3     cagradientlayer *newshadow = [[[Cagradientlayer Alloc] INIT] autorelease]; 4     CGRect newshadowframe = CGRectMake (0, 0, 5, frameheight); 5     newshadow.frame = newshadowframe; 6     // Add color combinations of gradients 7     newshadow.colors = [Nsarray arraywithobjects: (ID) [Uicolor blackcolor]. Cgcolor, (ID) [Uicolor clearcolor]. Cgcolor,nil]; 8     newshadow.startpoint=cgpointmake (0.0, 0.5); 9     Newshadow.endpoint=cgpointmake (1.0, 0.5);     NEWSHADOW;11}

Of course, this also requires you to set the transparency in the call, otherwise the effect is not good.

Simple gradient drawing for iOS

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.