UIButtonの基本プロパティと定義
4885 ワード
UIButton *button=[[UIButton buttonWithType:(UIButtonType);
定義できるbuttonタイプは以下の6種類あり、
typedef enum {
UIButtonTypeCustom = 0,
UIButtonTypeRoundedRect,
UIButtonTypeDetailDisclosure, ,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
} UIButtonType;
button1.frame = CGRectMake(20, 20, 280, 40);
[button setFrame:CGRectMake(20,20,50,50)];
button1.backgroundColor = [UIColor clearColor];
[button setBackgroundColor:[UIColor blueColor]];
enum {
UIControlStateNormal = 0,
UIControlStateHighlighted = 1 << 0,
UIControlStateDisabled = 1 << 1,
UIControlStateSelected = 1 << 2,
UIControlStateApplication = 0x00FF0000,
UIControlStateReserved = 0xFF000000 ,
};
@property(nonatomic,getter=isEnabled)BOOL enabled; // default is YES. if NO, ignores touch events and subclasses may draw differently
@property(nonatomic,getter=isSelected)BOOL selected; // default is NO may be used by some subclasses or by application
@property(nonatomic,getter=isHighlighted)BOOL highlighted;
[buttonsetImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];
[buttonsetBackgroundImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];
[button1 setTitle:@" " forState:UIControlStateNormal];
[buttonsetTitleColor:[UIColorredColor]forState:UIControlStateNormal];
button.showsTouchWhenHighlighted=NO;
[button1 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
[btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
UIEdgeInsets insets; //
insets.top = insets.bottom = insets.right = insets.left = 10;
bt.contentEdgeInsets = insets;
bt.titleEdgeInsets = insets; //