UIButton的使用
UIButton的代码实现:
定义:
UIButton * switchButton;
创建:
switchButton = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
添加到屏幕上:
[primaryView addSubview:switchButton];
修改属性的方法:
//Button的位置和大小
CGRect buttonRect = CGRectMake(BUTTON_X, BUTTON_Y, BUTTON_LENGTH, BUTTON_HEIGHT);
switchButton.frame = buttonRect;
//Button的字和颜色
[switchButtonsetTitle:@"滤镜效果" forState:UIControlStateNormal];
[switchButtonsetTitleColor:[UIColorcolorWithRed:255green:0blue:255alpha:1] forState:UIControlStateNormal];
//Button的背景图片
UIImage * tempButtonImg = [UIImage imageNamed:@"artwork.png"];
[switchButtonsetBackgroundImage:tempButtonImg forState:UIControlStateNormal];
设置响应和委托:
//设置UIButton的响应事件
[saveButtonaddTarget:selfaction:@selector(pressSaveButton:) forControlEvents:UIControlEventTouchUpInside];