In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What is the definition of UI basic UIButton, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Previously written UIWindow, UIViewController, those are some frameworks, the framework needs to be filled with specific view to form our application, mobile application development UI accounts for a large part, the most basic UI implementation is to use a variety of controls provided by the system, the other is a custom implementation, the author is currently an entry-level state, can only write basic controls.
IOS provides basic UI controls such as UIButton, UILable, UITextField, UIImageView, etc., which are inherited from UIView. Here first take UIButton to practice hand, why take UIButton, because UIbutton inherits from UIControl,UIControl and derived from UIView class, each control has a lot of view features, including the ability to attach to other views, all controls have a common set of properties and methods, including display content, click events, and so on. Subclasses of UIControl have event handling capabilities.
Definition of UIButton:
UIButton can be created using initWithFrame or buttonWithType:
1) initWithFrame
UIButton * btn= [[UIButton alloc] initWithFrame:CGRectMake (60,60,200,60)]; btn.backgroundColor= [UIColor greenColor]; [btn setTitle:@ "btn1" forState:UIControlStateNormal]; [self.view addSubview:btn]
2) buttonWithType
UIButton * btn2= [UIButton buttonWithType:UIButtonTypeRoundedRect]; CGRect rect=CGRectMake (60,160,200,60); btn2.frame=rect; btn2.tag=1001; btn2.backgroundColor= [UIColor colorWithRed:30/255.0 green:200/255.0 blue:125/255.0 alpha:1.0]; [btn2 setTitle:@ "btn2" forState:UIControlStateNormal]; [btn2 addTarget:self action:@selector (btn2Pressed) forControlEvents:UIControlEventTouchDown]; [self.view addSubview:btn2]
Btn2Pressed method:
(void) btn2Pressed {NSLog (@ "button pressed");}
UIButtonType:
Typedef enum {UIButtonTypeCustom = 0, / / no button type custom, no style UIButtonTypeRoundedRect, / / rounded rect, flat white button, like in address card white rounded rectangle, similar to the preference table cell or address book card UIButtonTypeDetailDisclosure,// blue disclosure button, can be placed next to any text UIButtonTypeInfoLight,// widget (widget) use the small circle information button Can be placed next to any text UIButtonTypeInfoDark,// white background using the dark circle information button UIButtonTypeContactAdd,// blue plus (+) button, can be placed next to any text} UIButtonType UIButton common properties:
/ / set the title content default is nil of the corresponding status. Title is assumed to be single line
-(void) setTitle: (NSString *) title forState: (UIControlState) state
/ / set the title color of the corresponding state
-(void) setTitleColor: (UIColor *) color forState: (UIControlState) state
/ / sets the title shadow color of the corresponding state
-(void) setTitleShadowColor: (UIColor *) color forState: (UIControlState) state
/ / set the picture of the button in the corresponding state
-(void) setImage: (UIImage *) image forState: (UIControlState) state
/ / set the button background image of the corresponding state
-(void) setBackgroundImage: (UIImage *) image forState: (UIControlState) state
UIControlState of UIButton:
Typedef NS_OPTIONS (NSUInteger, UIControlState) {UIControlStateNormal = 0, UIControlStateHighlighted = 1
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.