IOS UIButton attribute settings

Source: Internet
Author: User

IOS UIButton attribute settings
// Set the Custom button
// UIButton * button1 = [UIButton buttonWithType: UIButtonTypeCustom];
// Set a button for rounded corner
UIButton * button1 = [UIButton buttonWithType: UIButtonTypeRoundedRect];

Button1.frame = CGRectMake (80,250,250, 30); // coordinates of the button position
[Button1 setTitle: @ "Button1" forState: UIControlStateNormal]; // normal status button title
[Button1 setTitle: @ "highlighted state" forState: UIControlStateHighlighted]; // the title of the highlighted button
// Highlighted Halo Effect
[Button1 setShowsTouchWhenHighlighted: YES];
// Set the title Color
[Button1 setTitleColor: [UIColor redColor] forState: UIControlStateNormal];
// Set the font size of the title
[Button1.titleLabel setFont: [UIFont boldSystemFontOfSize: 20];
// Set the background color
[Button1 setBackgroundColor: [UIColor blueColor];
// The image is stretched to set the background image
[Button1 setBackgroundImage: [UIImage imageNamed: @ "1.jpg"] forState: UIControlStateNormal];
// Set the background image to keep the original size
// [Button1 setImage: [UIImage imageNamed: @ "1.jpg"] forState: UIControlStateNormal];
[[Button1 titleLabel] setShadowColor: [UIColor blackColor];
[[Button1 titleLabel] setShadowOffset: CGSizeMake (-0.5,-0.5)];
Button1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[Self. view addSubview: button1];
// Listen for events
[Button1 addTarget: self action: @ selector (Click_Button) forControlEvents: UIControlEventTouchUpInside];
}
-(Void) Click_Button
{
NSLog (@ "clicked ...");


}
Not complete, to be updated .........

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.