高类聚代码

UICollectionViewFlowLayout *layout = ({

UICollectionViewFlowLayout *layout =  [[UICollectionViewFlowLayout alloc] init];

layout.itemSize = CGSizeMake(cellWH, cellWH);

layout.minimumInteritemSpacing = margin;

layout.minimumLineSpacing = margin;

layout;

});

UICollectionView *collectionView = ({

UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, BSScreenW, 0) collectionViewLayout:layout];

collectionView.dataSource = self;

collectionView.delegate = self;

[collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([BSSquareCell class]) bundle:nil] forCellWithReuseIdentifier:ID];

collectionView.scrollEnabled = NO;

collectionView;

});

- (void)viewDidLoad {

[super viewDidLoad];

[self.view addSubview:({

UIView*view = [[UIView alloc]initWithFrame:(CGRect){100,200,200,200}];

view.backgroundColor = [UIColor redColor];

UIButton*butaicon= [UIButton buttonWithType:UIButtonTypeCustom];

butaicon.frame = (CGRect){75,75,50,50};

butaicon.backgroundColor = [UIColor yellowColor];

[butaicon setFont:[UIFont systemFontOfSize:14.0 weight:30.0]];

[butaicon setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];

[butaicon setTitle:@"点击" forState: UIControlStateNormal];

[butaicon addTarget:self action:@selector(buttAcion:) forControlEvents:UIControlEventTouchUpInside];

[view addSubview:butaicon];

UIButton*Maxbutton = [UIButton buttonWithType:UIButtonTypeCustom];

Maxbutton.frame = CGRectMake(0, 0, 400,600);

Maxbutton.alpha = 0.8;

[Maxbutton addTarget:self action:@selector(buttAcion2:) forControlEvents:UIControlEventTouchUpInside];

[Maxbutton addSubview:view];

Maxbutton;

})];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容