循环创建button、label、imageView

2018-06-12  本文已影响0人  Qy_iOS

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

    }

上一篇下一篇

猜你喜欢

热点阅读