//
// SelfMessViewController.m
// Cashier
//
// Created by ios2 on 15/10/7.
// Copyright © 2015年 sy. All rights reserved.
//
#import "SelfMessViewController.h"
#import "TopImgTabCell.h"
#import "OtherImgTabCell.h"
@interface SelfMessViewController ()
@end
@implementation SelfMessViewController
- (void)viewDidLoad {
[super viewDidLoad];
if (IOS7) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
UITableView * tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, NavContentHeight) style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundColor = [UIColor clearColor];
tableView.tableFooterView = [[UIView alloc]init];
tableView.separatorStyle = UITableViewCellSelectionStyleBlue;
[self.view addSubview:tableView];
//退出登陆
_backBtn =[[UIButton alloc] initWithFrame:CGRectMake(20, 270, ScreenWidth-40, 40)];
[_backBtn setBackgroundColor:[UIColor colorWithHex:0x80b0db alpha:1]];
_backBtn.layer.cornerRadius =5;
[_backBtn setTitle:@"退出登录" forState:UIControlStateNormal];
_backBtn.titleLabel.font =[UIFont fontWithName:FONTNAME size:18];
[tableView addSubview:_backBtn];
[self.view setBackgroundColor:[UIColor colorWithHex:0xeef2f8]];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 16.5;
if (scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0)
{
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
}
else if (scrollView.contentOffset.y >= sectionHeaderHeight)
{
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section==0) {
return 3;
}else{
return 1;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section==0&&indexPath.row==0) {
return 87.5;
}else {
return 45;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 16.5;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section==1) {
return 1;
}else{
return 0;
}
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView* top =[[UIView alloc] initWithFrame:CGRectMake(0,0,ScreenWidth,1)];
[top setBackgroundColor:[UIColor colorWithHex:0xcecece]];
return top;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 20)];
UIView* top =[[UIView alloc] initWithFrame:CGRectMake(0,0,ScreenWidth,1)];
[top setBackgroundColor:[UIColor colorWithHex:0xcecece]];
UIView* butt =[[UIView alloc] initWithFrame:CGRectMake(0,15.5,ScreenWidth,1)];
[butt setBackgroundColor:[UIColor colorWithHex:0xcecece]];
if (section==0) {
[view addSubview:butt];
}else if (section==1||section==2){
[view addSubview:top];
[view addSubview:butt];
}
view.backgroundColor = [UIColor clearColor];
return view;
}
-(UIView*)tableView:(UITableView *)tableView HeaderFooterView:(NSInteger)section
{
if (section==1) {
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
[view setBackgroundColor:[UIColor colorWithHex:0xcecece]];
return view;
}else{
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
[view setBackgroundColor:[UIColor clearColor]];
return view;
}
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section==0) {
if (indexPath.row==0) {
static NSString *CellTableIdentifier = @"CellTableIdentifier";
BOOL nibsRegistered = NO;
if (!nibsRegistered) {
UINib *nib = [UINib nibWithNibName:@"TopImgTabCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellTableIdentifier];
nibsRegistered = YES;
}
TopImgTabCell *cell = [tableView dequeueReusableCellWithIdentifier:
CellTableIdentifier];
User* user =[User createUser];
cell.lftLb.text =@"头像";
cell.lftLb.font =[UIFont fontWithName:FONTNAME size:17];
[cell.rgtImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",IMGSERVER,user.userheadimg]] placeholderImage:[UIImage imageNamed:@"sidebar_icon_head"]];
cell.rgtImg.layer.cornerRadius = cell.rgtImg.frame.size.width/2;
cell.rgtImg.layer.masksToBounds = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}else if (indexPath.row==1){
static NSString *CellTableIdentifier = @"CellTableIdentifier";
BOOL nibsRegistered = NO;
if (!nibsRegistered) {
UINib *nib = [UINib nibWithNibName:@"OtherImgTabCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellTableIdentifier];
nibsRegistered = YES;
}
OtherImgTabCell *cell = [tableView dequeueReusableCellWithIdentifier:
CellTableIdentifier];
User* user =[User createUser];
cell.lftLb.text =@"昵称";
cell.lftLb.font =[UIFont fontWithName:FONTNAME size:17];
cell.rgtLb.text =user.usernickname;
cell.rgtLb.font =[UIFont fontWithName:FONTNAME size:17];
cell.rgtLb.textColor =[UIColor grayColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}else{
static NSString *CellTableIdentifier = @"CellTableIdentifier";
BOOL nibsRegistered = NO;
if (!nibsRegistered) {
UINib *nib = [UINib nibWithNibName:@"OtherImgTabCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellTableIdentifier];
nibsRegistered = YES;
}
OtherImgTabCell *cell = [tableView dequeueReusableCellWithIdentifier:
CellTableIdentifier];
User* user =[User createUser];
cell.lftLb.text =@"性别";
cell.lftLb.font =[UIFont fontWithName:FONTNAME size:17];
if ([user.usersex isEqualToString:@"male"]) {
cell.rgtLb.text =@"女";
}else{
cell.rgtLb.text =@"男";
}
cell.rgtLb.font =[UIFont fontWithName:FONTNAME size:17];
cell.rgtLb.textColor =[UIColor grayColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
}else{
static NSString *CellTableIdentifier = @"CellTableIdentifier";
BOOL nibsRegistered = NO;
if (!nibsRegistered) {
UINib *nib = [UINib nibWithNibName:@"OtherImgTabCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellTableIdentifier];
nibsRegistered = YES;
}
User* user =[User createUser];
OtherImgTabCell *cell = [tableView dequeueReusableCellWithIdentifier:
CellTableIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.lftLb.text =@"修改手机号码";
cell.rgtLb.text =user.usermobile;
cell.rgtLb.textColor =[UIColor grayColor];
cell.lftLb.font =[UIFont fontWithName:FONTNAME size:17];
return cell;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
tabview
最新推荐文章于 2024-06-20 14:48:23 发布