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 发布