for (int i = 0; i < 6; i ++) {

        

        int n =  20 + i % 3 * 90 + i % 3 * 20;

        int m = 10 + i / 3 * 90 + i / 3 * 20;

        

        UIButton * bun = [UIButton buttonWithType:UIButtonTypeCustom];

        bun.frame = CGRectMake(n, m, 60, 60);

        

        [bun setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",[你的数组名字 objectAtIndex:i]]] forState:UIControlStateNormal];

        bun.tag = i + 1000;

        [bun addTarget:self action:@selector(buttonSix:) forControlEvents:UIControlEventTouchUpInside];

        

        [aView addSubview:bun];

 }

 

 

这是设置出来显示的是2行3列的九宫格。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2022-01-19
猜你喜欢
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-05-20
  • 2022-12-23
相关资源
相似解决方案