iphone UIButton 按钮初始化

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];
    }

猜你喜欢

转载自longquan.iteye.com/blog/1634189
今日推荐