//
// ViewController.m
// 06-应用管理
//
// Created by daier on 15/12/31.
// Copyright © 2015年 daier. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) NSArray *apps;
@end
@implementation ViewController
- (NSArray *)apps
{
if (_apps == nil) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"app.plist" ofType:nil];
_apps = [NSArray arrayWithContentsOfFile:path];
}
NSLog(@"%ld",_apps.count);
return _apps;
}
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat appW = ;
CGFloat appH = ;
int totalColoumns = ;
CGFloat marginX = (self.view.frame.size.width - totalColoumns*appW)/(totalColoumns+);
CGFloat marginY = ;
for (int index = ; index < self.apps.count; index++) {
UIView *appView = [[UIView alloc] init];
appView.backgroundColor = [UIColor redColor];
int row = index/totalColoumns;
int col = index%totalColoumns;
CGFloat appX = marginX + col*(appW + marginX);
CGFloat appY = + row*(appH + marginY);
appView.frame = CGRectMake(appX, appY, appW, appH);
[self.view addSubview:appView];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end