zoukankan      html  css  js  c++  java
  • 循环创建按钮

    #import "UserCell.h"

    #define kBorderX  5  // 左边

    #define kBorderY  0 // 上边

    #define kMargin  5

    #define kImageViewW  ([UIScreen mainScreen].bounds.size.width - kBorderX * 2 - kMargin * 6 ) / 7

    @interface UserCell ()

    @property (nonatomic, strong) NSMutableArray *imageViewArr;

    @end

    @implementation UserCell

    - (void)awakeFromNib {

        [super awakeFromNib];

        // Initialization code

        [self.imageViewArr removeAllObjects];

        for (NSInteger i = 0; i < 7; i++) {

            CGFloat x = kBorderX + (kMargin + kImageViewW) * i;

            UIImageView *imageView = [[UIImageView alloc] init];

            imageView.frame = CGRectMake(x, kBorderY, kImageViewW, kImageViewW);

            imageView.backgroundColor = [UIColor redColor];

            imageView.userInteractionEnabled = YES;

            [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickImage:)]];

            imageView.layer.cornerRadius = kImageViewW * 0.5;

            imageView.layer.masksToBounds = YES;

            [self.imageViewArr addObject:imageView];

            [self.contentView addSubview:imageView];

            

        }

    }

    1
  • 相关阅读:
    25.Kafka(三):面试题
    24.Kafka(二):API
    23.Kafka(一):概述
    22.Flume监控、自定义组件、面试题
    21.Flume概述和企业开发案例
    20.Hive企业调优
    19.Hive函数、存储压缩
    18.Hive数据查询
    17.Hive数据操作
    16.Hive基础
  • 原文地址:https://www.cnblogs.com/fantasy3588/p/5352210.html
Copyright © 2011-2022 走看看