//
Mineviewcontroller.m
//
#import "MineViewController.h"
#import "ConstantHeader.h"
#import <Masonry/Masonry.h>
#import "MineTableViewCell.h"
@interface Mineviewcontroller () <UITableViewDelegate,UITableViewDataSource>
@property (Nonatomic,strong) UITableView *mytableview;
@property (Nonatomic,strong) nsmutablearray<nsstring *> *dataarr;
@property (Nonatomic,strong) UIButton *guanzhubtn;
@property (Nonatomic,strong) UIButton *fensibtn;
@property (Nonatomic,strong) Uilabel *beizhanbtn;
@property (Nonatomic,strong) Uilabel *beishoucangbtn;
@end
@implementation Mineviewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Self.navigationController.navigationBar.translucent = YES;
Self.mytableview = [[UITableView alloc] Initwithframe:cgrectzero style:uitableviewstylegrouped];
[Self.view AddSubview:self.myTableView];
[Self.mytableview mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.center.mas_equalTo (Self.view);
Make.size.mas_equalTo (Self.view);
}];
Self.myTableView.delegate = self;
Self.myTableView.dataSource = self;
Self.myTableView.estimatedRowHeight = 40;
Self.myTableView.rowHeight = uitableviewautomaticdimension;
Self.myTableView.backgroundColor = Normal_bkg_grey;
[Self.mytableview Registerclass:[minetableviewcell class] forcellreuseidentifier:@ "Minetableviewcell"];
Set TableView offset Top
Self.myTableView.contentOffset = Cgpointmake (0.0, 0.0);
UIView *hview = [[UIView alloc]initwithframe:cgrectmake (0, 0, screen_size_width, 180)];
UIView *headerbkgview = [[UIView alloc]init];
[Hview Addsubview:headerbkgview];
[Headerbkgview mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.top.mas_equalTo (0);
Make.left.mas_equalTo (0);
Make.width.mas_equalTo (Screen_size_width);
Make.height.mas_equalTo (200);
}];
Headerbkgview.backgroundcolor = Main_theme_color;
Uiimageview *HEADIMGV = [[Uiimageview alloc]init];
[Headerbkgview ADDSUBVIEW:HEADIMGV];
[HEADIMGV mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.centerX.mas_equalTo (Headerbkgview.mas_centerx);
Make.top.mas_equalTo (headerbkgview.mas_top). Mas_offset (35);
Make.size.mas_equalTo (Cgsizemake (85, 85));
}];
HeadImgv.layer.cornerRadius = 85/2;
HeadImgv.layer.masksToBounds = YES;
Headimgv.backgroundcolor = [Uicolor Whitecolor];
Name
Uilabel *namelabel = [[Uilabel alloc]init];
[Headerbkgview Addsubview:namelabel];
[Namelabel mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.top.mas_equalTo (Headimgv.mas_bottom). Mas_offset (text_line_distance);
Make.centerX.mas_equalTo (Headimgv.mas_centerx);
Make.left.mas_equalTo (text_edge_distance);
Make.width.mas_greaterThanOrEqualTo (5);
Make.height.mas_lessThanOrEqualTo (35);
}];
Namelabel.font = Middle_second_font;
Namelabel.textcolor = [Uicolor Whitecolor];
Namelabel.text = @ "haha haha";
Namelabel.textalignment = Nstextalignmentcenter;
Address
Uilabel *addressl = [[Uilabel alloc]init];
[Headerbkgview Addsubview:addressl];
[Addressl mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.top.mas_equalTo (Namelabel.mas_bottom). Mas_offset (text_line_distance);
Make.centerX.mas_equalTo (Headimgv.mas_centerx). Mas_offset (10);
Make.left.mas_greaterThanOrEqualTo (TEXT_LINE_DISTANCE+15);
Make.width.mas_greaterThanOrEqualTo (5);
}];
Addressl.font = Little_font;
Addressl.textcolor = [Uicolor Whitecolor];
Addressl.text = @ "Heilongjiang province Jiamusi";
Icon
Uiimageview *addressicon = [[Uiimageview alloc]init];
[Headerbkgview Addsubview:addressicon];
[Addressicon mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.centerY.mas_equalTo (Addressl.mas_centery);
Make.right.mas_equalTo (Addressl.mas_left). Mas_offset (-5);
Make.size.mas_equalTo (Cgsizemake (15, 15));
}];
Addressicon.image = [UIImage imagenamed:@ "temp_address"];
[Headerbkgview mas_remakeconstraints:^ (Masconstraintmaker *make) {
Make.top.mas_equalTo (0);
Make.left.mas_equalTo (0);
Make.width.mas_equalTo (Screen_size_width);
Make.height.mas_equalTo (200);
}];
Specify Tableheaderview
CGFloat height = [Headerbkgview systemlayoutsizefittingsize:uilayoutfittingcompressedsize].height;
CGRect frame = headerbkgview.frame;
Frame.size.height = height;
Headerbkgview.frame = frame;
Self.myTableView.tableHeaderView = Headerbkgview;
Self.dataarr = [@[@ "My centimeter", @ "Income statistics" @ "voucher", @ "list" @ "My Search" @ "Address Management" @ "Customer Service" @ "Message Center", @ "my notes"] mutablecopy];
}
-(void) Viewwillappear: (BOOL) animated{
[Super viewwillappear:animated];
Unified navigation Style
[Self.navigationController.navigationBar Setbackgroundimage:[[uiimage alloc] init] Forbarmetrics: Uibarmetricsdefault];
Remove the black edges below the transparent navigation bar
[Self.navigationController.navigationBar Setshadowimage:[[uiimage alloc] init];
}
-(void) Viewwilldisappear: (BOOL) animated{
[Super viewwilldisappear:animated];
Unified navigation Style
[Self.navigationController.navigationBar Setbackgroundimage:nil Forbarmetrics:uibarmetricsdefault];
[Self.navigationController.navigationBar Setshadowimage:nil];
}
Set TableView cannot pull down
-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView {
Cgpoint point = Scrollview.contentoffset;
if (point.y <= 0) {
Self.myTableView.contentOffset = Cgpointmake (0.0, 0.0);
}
}
#pragma mark-----TableView Agent Event-----
-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{
return 1;
}
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) section{
return self.dataArr.count;
}
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexPath{