本地plist文件实现瀑布流照片墙
@property (nonatomic,strong) NSMutableArray *plistArray;
@property (nonatomic,strong) NSMutableArray *showArray;
@property (nonatomic,copy) UICollectionView *theCollectionView;
两个可变数组用来存放图片,
-(NSMutableArray *)plistArray{
if (!_plistArray) {
_plistArray=[[NSMutableArray alloc]init];
}
NSString *path=[[NSBundle mainBundle]pathForResource:@"photos" ofType:@"plist"];
NSDictionary *dic=[NSDictionary dictionaryWithContentsOfFile:path];
for (NSDictionary *dic_22 in dic[@"content"]) {
PlistModel *plist=[[PlistModel alloc]init];
[plist setValuesForKeysWithDictionary:dic_22];
[_plistArray addObject:plist];
}
return _plistArray;
}
获取图片资源
YCCollectionViewLayout文件未上传
YCCollectionViewLayout *layout=[[YCCollectionViewLayout alloc]initWithCloumnCount:3];
[layout setCloumnSpacingWidth:5 rowSpacingHeight:5 borderSet:UIEdgeInsetsMake(5, 5, 5, 5)];
layout.delegate=self;
_theCollectionView=[[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];
_theCollectionView.delegate=self; _theCollectionView.dataSource=self;
_theCollectionView.backgroundColor=[UIColor whiteColor];
[_theCollectionView registerNib:[UINib nibWithNibName:@"PlistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"a"];
[self.view addSubview:self.theCollectionView];
网格设置
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Add" style:UIBarButtonItemStylePlain target:self action:@selector(add:)];
_showArray=[NSMutableArray new];
初始化用来展示图片的数组,导航右按钮,
![](https://img.haomeiwen.com/i5636414/bbc602356fea91a9.png)
![](https://img.haomeiwen.com/i5636414/287ef8c7545f575c.png)
![](https://img.haomeiwen.com/i5636414/9f05d6862dac5e2a.png)
![](https://img.haomeiwen.com/i5636414/8dedb5b9ae73e872.png)
![](https://img.haomeiwen.com/i5636414/c4746d0263220a92.png)
![](https://img.haomeiwen.com/i5636414/37c0717120c9e865.png)
网友评论