1、UIImageView 设置内容的Mode的方法
imageView.contentMode = UIViewContentModeScaleAspectFill;
2、UICollectionViewCell Custom的方法
CustomUICollectionViewCell.m
- (id)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self initUI]; } return self; } - (void)initUI{
//TODO }
然后在collectionView中注册这个CustomUICollectionViewCell
UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init]; collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout]; [collectionView setTranslatesAutoresizingMaskIntoConstraints:NO]; [collectionView setBackgroundColor:[UIColor clearColor]]; [collectionView registerClass:[CustomCollectionViewCell class] forCellWithReuseIdentifier:@"MY_CELL"]; collectionView.dataSource = self; collectionView.delegate = self;
最后在datasource函数中复用Cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { CustomCollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath]; return cell; }
这就是CollectionViewCell的Custom流程
3、ios modal segue code
- (IBAction)pushMyNewViewController { MyNewViewController *myNewVC = [[MyNewViewController alloc] init]; // do any setup you need for myNewVC [self presentModalViewController:myNewVC animated:YES];//被弃用
[self presentViewController:viewController animated:YES completion:nil];//被这个代替
}
[self dismissViewControllerAnimated:YES completion:nil]; //dismiss view