|
|
@@ -8,7 +8,7 @@
|
|
|
|
|
|
#import "PreferencesViewController.h"
|
|
|
#import "BAKit_BAGridView.h"
|
|
|
-static NSString * const kCellID = @"ViewControllerCell";
|
|
|
+static NSString * const kCellID = @"PreferencesViewControllerCellID";
|
|
|
#define AvatarWH 60
|
|
|
#define ProgressH 8
|
|
|
#define MaxX(view) CGRectGetMaxX(view.frame)
|
|
|
@@ -16,26 +16,68 @@ static NSString * const kCellID = @"ViewControllerCell";
|
|
|
//#define MaxXPlus(MaxX(v),plusnumber) (MaxX(v) + plusnumber)
|
|
|
//Avatar frame
|
|
|
#define ScreenMarginTBLR 20
|
|
|
-@interface PreferencesViewController()//<UITableViewDelegate,UITableViewDataSource>
|
|
|
+
|
|
|
+
|
|
|
+//gridView
|
|
|
+#define kGridView_rowCount 4
|
|
|
+#define kGridView_itemHeight 100
|
|
|
+#define kGridView_H BAKit_getColumnCountWithArrayAndRowCount_pod(self.gridDataArray, kGridView_rowCount) * kGridView_itemHeight
|
|
|
+@interface PreferencesViewController()<UITableViewDelegate,UITableViewDataSource>
|
|
|
@property(nonatomic,weak)UIImageView *avatarview;
|
|
|
@property(nonatomic,weak)UIProgressView *progressview;
|
|
|
@property(nonatomic, weak)BAGridView *gridView;
|
|
|
-//@property(nonatomic,weak)UIView *gridView;//九宫格view,待自定义
|
|
|
+@property(nonatomic,strong)NSMutableArray *gridDataArray;
|
|
|
+
|
|
|
@property(nonatomic,weak)UITableView *tableview;
|
|
|
+@property(nonatomic,strong)NSArray *tableDataArray;
|
|
|
@end
|
|
|
@implementation PreferencesViewController
|
|
|
+- (NSMutableArray <BAGridItemModel *> *)gridDataArray
|
|
|
+{
|
|
|
+ if (!_gridDataArray)
|
|
|
+ {
|
|
|
+ _gridDataArray = @[].mutableCopy;
|
|
|
+
|
|
|
+ // 可以为本地图片
|
|
|
+ // NSArray *imageNameArray = @[@"tabbar_mainframeHL", @"tabbar_mainframeHL", @"tabbar_mainframeHL", @"tabbar_mainframeHL", @"tabbar_mainframeHL"];
|
|
|
+ // 也可以是网络图片
|
|
|
+ NSArray *imageNameArray = @[@"gridviewtest.png", @"gridviewtest.png", @"gridviewtest.png", @"gridviewtest.png", @"gridviewtest.png"];
|
|
|
+
|
|
|
+ NSArray *titleArray = @[@"测试", @"测试", @"测试", @"测试", @"测试"];
|
|
|
+
|
|
|
+ for (NSInteger i = 0; i < titleArray.count; i++)
|
|
|
+ {
|
|
|
+ BAGridItemModel *model = [BAGridItemModel new];
|
|
|
+ model.imageName = imageNameArray[i];
|
|
|
+ model.placdholderImageName = @"tabbar_mainframeHL";
|
|
|
+ model.titleString = titleArray[i];
|
|
|
+
|
|
|
+ [self.gridDataArray addObject:model];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return _gridDataArray;
|
|
|
+}
|
|
|
+-(NSArray *)tableDataArray{
|
|
|
+ if (!_tableDataArray) {
|
|
|
+ _tableDataArray = [[NSArray alloc]initWithObjects:@"设置",@"用户反馈",@"关于", nil];
|
|
|
+ }
|
|
|
+ return _tableDataArray;
|
|
|
+}
|
|
|
-(void)viewDidLoad{
|
|
|
[super viewDidLoad];
|
|
|
+ self.view.backgroundColor = RGB(243, 243, 245);
|
|
|
self.navigationController.navigationBar.hidden = YES;
|
|
|
[self initSubViews];
|
|
|
+ [self initData];
|
|
|
}
|
|
|
-(void)initSubViews{
|
|
|
//|----|namelabel
|
|
|
//|头像 |progress
|
|
|
//|____|descritionlabel
|
|
|
CGFloat screenW = SCREEN_WIDTH;
|
|
|
+ CGFloat screenH = SCREEN_HEIGHT;
|
|
|
CGFloat residualRightW;
|
|
|
- CGFloat residualRightH;
|
|
|
+ CGFloat residualRightH;//可用户布局 剩余高度
|
|
|
UIImageView *avatarview = [[UIImageView alloc]init];
|
|
|
avatarview.layer.cornerRadius = AvatarWH/2;
|
|
|
avatarview.layer.masksToBounds = YES;
|
|
|
@@ -66,15 +108,75 @@ static NSString * const kCellID = @"ViewControllerCell";
|
|
|
descritionlab.backgroundColor = [UIColor grayColor];
|
|
|
descritionlab.frame = CGRectMake(progressview.origin.x, CGRectGetMaxY(progressview.frame), residualRightW, 30);
|
|
|
[self.view addSubview:descritionlab];
|
|
|
- UIView *gridView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(avatarview.frame)+20, screenW, 200)];
|
|
|
- gridView.backgroundColor = [UIColor blueColor];
|
|
|
- [self.view addSubview:gridView];
|
|
|
- self.gridView = gridView;
|
|
|
|
|
|
- UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(gridView.frame), screenW, 300) style:UITableViewStylePlain];
|
|
|
- tableView.separatorColor = [UIColor clearColor];
|
|
|
+
|
|
|
+ BAGridView *gridview = [BAGridView ba_creatGridViewWithGridViewType:BAGridViewTypeImageTitle dataArray:self.gridDataArray configurationBlock:^(BAGridView *tempView) {
|
|
|
+
|
|
|
+ // 是否显示分割线
|
|
|
+ tempView.showLineView = YES;
|
|
|
+ // item:分割线颜色,默认:BAKit_Color_Gray_11【BAKit_Color_RGB(248, 248, 248)】
|
|
|
+ tempView.ba_gridView_lineColor = RGB(240, 240, 242);
|
|
|
+ // item:每行 item 的个数,默认为4个
|
|
|
+ tempView.ba_gridView_rowCount = kGridView_rowCount;
|
|
|
+ // item:高度
|
|
|
+ tempView.ba_gridView_itemHeight = kGridView_itemHeight;
|
|
|
+ // item:图片与文字间距(或者两行文字类型的间距),默认:0
|
|
|
+ // tempView.ba_gridView_itemImageInset = 10;
|
|
|
+ // item:title 颜色,默认:BAKit_Color_Black【[UIColor blackColor]】
|
|
|
+ // tempView.ba_gridView_titleColor = BAKit_Color_Black;
|
|
|
+ // item:title Font,默认:图文样式下 16,两行文字下(上25,下12)
|
|
|
+ tempView.ba_gridView_titleFont = [UIFont boldSystemFontOfSize:15];
|
|
|
+ // item:背景颜色,默认:BAKit_Color_White
|
|
|
+ tempView.ba_gridView_backgroundColor = [UIColor whiteColor];
|
|
|
+ // item:背景选中颜色,默认:无色
|
|
|
+ tempView.ba_gridView_selectedBackgroundColor = BAKit_Color_Red_pod;
|
|
|
+
|
|
|
+ self.gridView = tempView;
|
|
|
+
|
|
|
+ } block:^(BAGridItemModel *model, NSIndexPath *indexPath) {
|
|
|
+
|
|
|
+ // BAKit_ShowAlertWithMsg_ios8(model.titleString);
|
|
|
+ }];
|
|
|
+ gridview.frame = CGRectMake(0, CGRectGetMaxY(avatarview.frame)+20, screenW, kGridView_H);
|
|
|
+ [self.view addSubview:gridview];
|
|
|
+ self.gridView = gridview;
|
|
|
+
|
|
|
+ residualRightH =screenH - CGRectGetMaxY(gridview.frame) +20;
|
|
|
+
|
|
|
+
|
|
|
+ UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(gridview.frame)+20, screenW, residualRightH) style:UITableViewStylePlain];
|
|
|
+ //footview
|
|
|
+ UIView *footview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, 54)];
|
|
|
+ UIButton *exitBtn = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
|
+ [exitBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
|
|
|
+ [exitBtn setTitle:@"退出账户" forState:UIControlStateNormal];
|
|
|
+ exitBtn.backgroundColor = [UIColor whiteColor];
|
|
|
+ exitBtn.frame = CGRectMake(0, 10, screenW, 44);
|
|
|
+
|
|
|
+ [footview addSubview:exitBtn];
|
|
|
+ tableView.backgroundColor = [UIColor clearColor];
|
|
|
+ tableView.tableFooterView = footview;
|
|
|
[self.view addSubview:tableView];
|
|
|
+ tableView.dataSource = self;
|
|
|
+ tableView.delegate = self;
|
|
|
self.tableview = tableView;
|
|
|
}
|
|
|
-
|
|
|
+-(void)initData{
|
|
|
+ [self.progressview setProgress:.34 animated:YES];
|
|
|
+}
|
|
|
+-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
+ return 3;
|
|
|
+}
|
|
|
+-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
|
|
|
+ if (!cell) {
|
|
|
+ cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kCellID];
|
|
|
+ }
|
|
|
+ cell.textLabel.text = self.tableDataArray[indexPath.row];
|
|
|
+ return cell;
|
|
|
+}
|
|
|
+-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
+ NSLog(@"tap %@",indexPath);
|
|
|
+ NSLog(@"cell text: %@",[[[tableView cellForRowAtIndexPath:indexPath]textLabel]text]);
|
|
|
+}
|
|
|
@end
|