循环创建button、label、imageView

for (int i = 0; i < _imageArr.count; i++) {

        _fristnumBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _fristnumBtn.frame = CGRectMake(42*unitPX+i*121*unitPX, 15*unitPX, 30*unitPX, 30*unitPX);

//        _fristnumBtn.backgroundColor = [UIColor blackColor];

        [_fristnumBtn setImage:[UIImage imageNamed:_imageArr[i]] forState:0];

        _fristnumBtn.tag = 500+i;

        [_fristnumBtn addTarget:self action:@selector(myPushVC:) forControlEvents:UIControlEventTouchUpInside];

        [_bjView addSubview: _fristnumBtn];

    }

你可能感兴趣的:(循环创建button、label、imageView)