for (int i=0; i<9; i++) {
UIButton *roundedRectButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGRect buttonRect = CGRectMake(18+(i%9%3)*105+(i/9)*320, 35+(i%9/3)*105, 80, 80);
[roundedRectButton setFrame:buttonRect];
//[roundedRectButton setTitle:@"Normal" forState:UIControlStateNormal];
[roundedRectButton setTitle:@"Highlighted" forState:UIControlStateHighlighted];
roundedRectButton.showsTouchWhenHighlighted = YES;
[roundedRectButton setTag:i];
[roundedRectButton setBackgroundImage:[UIImage imageNamed:@"logo.jpg"] forState:UIControlStateNormal];
[roundedRectButton addTarget:self action:@selector(buttonDown:) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:roundedRectButton];
}
iphone UIButton 按钮初始化
最新推荐文章于 2022-08-19 21:25:16 发布
本文将指导您如何使用Objective-C编程语言创建一个带有自定义背景图像和状态切换功能的圆角矩形按钮控件。
167

被折叠的 条评论
为什么被折叠?



