IOS-UIButton?????????????
???????????? ???????[ 2014/8/4 11:36:21 ] ??????????? ???
????UIButton??????????UIControl???
???????????
?????????????
????1. ????? initWithFrame
????UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectMake(10?? 10?? 80?? 44)];
???????????View??UIControl?????UIView?????????view????????????ο??????й?View?????????????
????2. UIButton ????????????????????????????buttonWithType
????UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
?????????????
typedef enum {
UIButtonTypeCustom = 0?? // no button type ????壬????
UIButtonTypeRoundedRect?? // rounded rect?? flat white button?? like in address card ????????Σ??????????????????????????
UIButtonTypeDetailDisclosure??//???????????????????κ???????
UIButtonTypeInfoLight??//???(widget)????С??????????????????κ???????
UIButtonTypeInfoDark??//????????????????????????
UIButtonTypeContactAdd??//??????(+)?????????????κ???????
} UIButtonType;
????????????????
????1.Frame????
??????2?????????????????????????frame?????????????CGRect??????????λ?ú??С
????CGRect btn2Frame = CGRectMake(10.0?? 10.0?? 60.0?? 44.0);
????btn2.frame =btn2Frame;
????2. title????
?????????κ???????μ????????????趨?e???????μ?????????setTitle ???? ???ü????
????[btn1 setTitle:@"BTN1" forState:UIControlStateNormal];
??????????????????????????????? setImage ?????
????[btn2 setImage:[UIImage imageNamed:@"pic"] forState:UIControlStateNormal];
????????????????????????????????????????????????????????? setTitleColor ?? setTitleShadowColor ????????UIColor????????????
????[btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];//??????????
????[btn1 setTitleShadowColor:[UIColor grayColor] forState:UIControlStateNormal ];//???
????[btn1 setBackgroundImage:[UIImage imageNamed:@"PIC"] forState:UIControlStateHighlighted];//???????
???????漸?????????? ???????? forState . ?????????????????????????????????????????????????????????????仯
enum {
UIControlStateNormal = 0?? //???
UIControlStateHighlighted = 1 << 0?? // used when UIControl isHighlighted is set ????
UIControlStateDisabled = 1 << 1?? //????
UIControlStateSelected = 1 << 2?? // flag usable by app (see below) ???
UIControlStateApplication = 0x00FF0000?? // additional flags available for application use ????ó?????????
UIControlStateReserved = 0xFF000000 // flags reserved for internal framework use ???????????
};
typedef NSUInteger UIControlState;
????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11