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 按钮初始化
猜你喜欢
转载自longquan.iteye.com/blog/1634189
今日推荐
周排行