UIButton sets the shadow effect and uibutton sets the shadow effect.

Source: Internet
Author: User

UIButton sets the shadow effect and uibutton sets the shadow effect.

UIButton sometimes needs to use code to adjust the style, including adding a shadow.


As shown in the login button




In this case, you need to consider setting the button layer.

Button layer sets the following attributes

CornerRadius;

ShadowOffset

ShadowOpacity;

ShadowColor;



The Code is as follows:

LoginBtn = [UIButton buttonWithType: UIButtonTypeCustom]; loginBtn. frame = CGRectMake (10,120, 88, 36); loginBtn. backgroundColor = [UIColor colorwithred: 44/255. 0 green: 178/255. 0 blue: 219/255. 0 alpha: 1.0]; loginBtn. layer. cornerRadius = 5; loginBtn. layer. shadowOffset = CGSizeMake (1, 1); loginBtn. layer. shadowOpacity = 0.8; loginBtn. layer. shadowColor = [UIColor blackColor]. CGColor; [loginBtn setTitle: @ "login" forState: UIControlStateNormal]; [self. view addSubview: loginBtn];







Apple Development Group: 414319235 welcome to join discussions


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.