支付宝

2017-12-21  本文已影响0人  一只放生的小哈哈

AppDelegate里面的内容

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecViewController.h"
#import "ThreeViewController.h"
#import "FourViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    // 创建控制器
    FirstViewController *fVC = [[FirstViewController alloc]init];
    // 创建导航控制器
    UINavigationController *fNav = [[UINavigationController alloc]initWithRootViewController:fVC];
    // 创建标签控制器
    UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"DD"] selectedImage:[UIImage imageNamed:@"DD_H"]];
    // 把控制器赋给导航控制器
    fNav.tabBarItem = item1;
   
   
    // 创建控制器
    SecViewController *sVC = [[SecViewController alloc]init];
    // 创建导航控制器
    UINavigationController *sNav = [[UINavigationController alloc]initWithRootViewController:sVC];
    // 创建标签控制器
    UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"口碑" image:[UIImage imageNamed:@"dongTai"] selectedImage:[UIImage imageNamed:@"dongTai_H"]];
    // 把控制器赋给导航控制器
    sNav.tabBarItem = item2;
    // 创建控制器
    ThreeViewController *tVC = [[ThreeViewController alloc]init];
    // 创建导航控制器
    UINavigationController *tNav = [[UINavigationController alloc]initWithRootViewController:tVC];
    // 创建标签控制器
    UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"朋友" image:[UIImage imageNamed:@"DD"] selectedImage:[UIImage imageNamed:@"DD_H"]];
    // 把控制器赋给导航控制器
    tNav.tabBarItem = item3;
    // 创建控制器
    FourViewController *FVC = [[FourViewController alloc]init];
    // 创建导航控制器
    UINavigationController *FNav = [[UINavigationController alloc]initWithRootViewController:FVC];
    // 创建标签控制器
    UITabBarItem *item4 = [[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"dongTai"] selectedImage:[UIImage imageNamed:@"dongTai_H"]];
    // 把控制器赋给导航控制器
    FNav.tabBarItem = item4;
   
    UITabBarController *tabBar = [[UITabBarController alloc]init];
   
    tabBar.viewControllers = @[fNav,sNav,tNav,FNav];
   
    self.window.rootViewController = tabBar;

    return YES;
}

// 自定义cell

.H文件里面的

@property (nonatomic,strong)UIImageView *headImage;
@property (nonatomic,strong)UILabel *titLabel;
@property (nonatomic,strong)UILabel *subLabel;

@property (nonatomic,strong)UILabel *timeLabel;

.M文件里面的

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.headImage];
        [self.contentView addSubview:self.titLabel];
        [self.contentView addSubview:self.subLabel];
        [self.contentView addSubview:self.timeLabel];
    }
    return self;
}


-(UIImageView *)headImage
{
    if (!_headImage) {
        // 初始化
        _headImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 40, 40)];
        // 设置圆角属性
        _headImage.layer.cornerRadius = 20;
        _headImage.layer.masksToBounds = YES;
    }
    return _headImage;
}

- (UILabel *)titLabel
{
    if (!_titLabel) {
        // 初始化label
        _titLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 5, 100, 30)];
        // 设置Label的字体
        _titLabel.font = [UIFont systemFontOfSize:16];
       
    }
    return _titLabel;
}

- (UILabel *)subLabel
{
    if (!_subLabel) {
        // 初始化label
        _subLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 30, 350, 20)];
        // 设置label的字体
        _subLabel.font = [UIFont systemFontOfSize:12];
    }
    return _subLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel) {
        // 初始化Label
        _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(350, 10, 40, 40)];
        // 设置字体
        _timeLabel.font = [UIFont systemFontOfSize:12];
    }
    return _timeLabel;
}

// 第三个控制器里面的

#import "ThreeViewController.h"#import "FriendTableViewCell.h"@interface ThreeViewController (){

UITableView *_tableView;

NSMutableDictionary *data;

}

@end

@implementation ThreeViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.navigationItem.title = @"朋友";

// 设置导航控制器的背景颜色

self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:25/255.0 green:108/255.0 blue:198/255.0 alpha:1.0];

// 设置背景颜色

self.view.backgroundColor = [UIColor whiteColor];

// 初始化TableView

_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 70, self.view.frame.size.width, 300) style:UITableViewStylePlain];

// 设置代理

_tableView.delegate = self;

_tableView.dataSource = self;

_tableView.rowHeight = 60;

// 将TableView添加到视图上

[self.view addSubview:_tableView];

}

// 设置行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return 5;

}

// 数据源方法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

FriendTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

if (!cell)

{

cell = [[FriendTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

}

if (indexPath.row == 0)

{

cell.headImage.image = [UIImage imageNamed:@"1.jpg"];

cell.titLabel.text = @"生活号";

cell.subLabel.text = @"哈哈哈哈哈哈";

cell.timeLabel.text = @"昨天";

}

if (indexPath.row == 1)

{

cell.headImage.image = [UIImage imageNamed:@"2.jpg"];

cell.titLabel.text = @"张森";

cell.subLabel.text = @"吃鸡大神";

cell.timeLabel.text = @"昨天";

}

if (indexPath.row == 2)

{

cell.headImage.image = [UIImage imageNamed:@"3.jpg"];

cell.titLabel.text = @"张昆";

cell.subLabel.text = @"吃鸡菜鸡";

cell.timeLabel.text = @"昨天";

}

if (indexPath.row == 3)

{

cell.headImage.image = [UIImage imageNamed:@"4.jpg"];

cell.titLabel.text = @"大狗";

cell.subLabel.text = @"傻狗一只";

cell.timeLabel.text = @"昨天";

}

if (indexPath.row == 4)

{

cell.headImage.image = [UIImage imageNamed:@"5.jpg"];

cell.titLabel.text = @"小狗";

cell.subLabel.text = @"哈哈哈哈哈哈";

cell.timeLabel.text = @"昨天";

}

return cell;

}

//第四个控制器里面的

@interface FourViewController (){

UITableView *_tableView;

NSArray *_imageArr;

NSArray *_titleArr;

}

@end

@implementation FourViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.view.backgroundColor = [UIColor whiteColor];

// 设置导航控制器的背景颜色

self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:25/255.0 green:108/255.0 blue:198/255.0 alpha:1.0];

self.navigationItem.title = @"我的";

_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 60, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];

// 设置代理

_tableView.delegate = self;

_tableView.dataSource = self;

[self.view addSubview:_tableView];

_imageArr = @[@"1.jpg",@"2.jpg"];

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

return 3;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

if (section == 0)

{

return 2;

}

else if (section == 1)

{

return 6;

}

return 4;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

if (!cell)

{

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];

}

if (indexPath.section == 0)

{

if (indexPath.row == 0)

{

cell.backgroundColor = [UIColor colorWithRed:25/255.0 green:108/255.0 blue:198/255.0 alpha:1.0];

cell.imageView.image = [UIImage imageNamed:@"1.jpg"];

UILabel *titName = [[UILabel alloc]initWithFrame:CGRectMake(80, 25, 90, 30)];

titName.text = @"白玉霜";

[cell.contentView addSubview:titName];

UILabel *subName = [[UILabel alloc]initWithFrame:CGRectMake(80, 50, 230, 30)];

subName.text = @"www.baidu.com";

subName.font = [UIFont systemFontOfSize:12];

[cell.contentView addSubview:subName];

UILabel *titLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 30, 90, 20)];

titLabel.font = [UIFont systemFontOfSize:13];

titLabel.text = @"未设置昵称";

[cell.contentView addSubview:titLabel];

}

if (indexPath.row == 1) {

cell.imageView.image = [UIImage imageNamed:@"2.jpg"];

cell.textLabel.text = @"蚂蚁会员";

cell.detailTextLabel.text = @"你有积分即将到期";

cell.detailTextLabel.font = [UIFont systemFontOfSize:13];

}

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

}

if (indexPath.section == 1) {

if (indexPath.row == 0) {

cell.imageView.image =  [UIImage imageNamed:@"3.jpg"];

cell.textLabel.text = @"账单";

}

if (indexPath.row == 1) {

cell.imageView.image =  [UIImage imageNamed:@"4.jpg"];

cell.textLabel.text = @"总资产";

cell.detailTextLabel.text = @"账户安全保障中";

cell.detailTextLabel.textColor = [UIColor colorWithRed:107/255.0 green:175/255.0 blue:156/255.0 alpha:1.0];

cell.detailTextLabel.font = [UIFont systemFontOfSize:13];

}

if (indexPath.row == 2) {

cell.imageView.image =  [UIImage imageNamed:@"1.jpg"];

cell.textLabel.text = @"余额";

cell.detailTextLabel.text = @"0.00元";

//            cell.detailTextLabel.textColor = [UIColor colorWithRed:107/255.0 green:175/255.0 blue:156/255.0 alpha:1.0];

//            cell.detailTextLabel.font = [UIFont systemFontOfSize:13];

}

if (indexPath.row == 3) {

cell.imageView.image =  [UIImage imageNamed:@"2.jpg"];

cell.textLabel.text = @"余额宝";

}

if (indexPath.row == 4) {

cell.imageView.image =  [UIImage imageNamed:@"3.jpg"];

cell.textLabel.text = @"余利宝";

}

if (indexPath.row == 5) {

cell.imageView.image =  [UIImage imageNamed:@"4.jpg"];

cell.textLabel.text = @"银行卡";

}

}

if (indexPath.section == 2) {

if (indexPath.row == 0) {

cell.imageView.image =  [UIImage imageNamed:@"1.jpg"];

cell.textLabel.text = @"蚂蚁财富";

}

if (indexPath.row == 1) {

cell.imageView.image =  [UIImage imageNamed:@"2.jpg"];

cell.textLabel.text = @"芝麻信用";

}

if (indexPath.row == 2) {

cell.imageView.image =  [UIImage imageNamed:@"3.jpg"];

cell.textLabel.text = @"保险服务";

}

if (indexPath.row == 3) {

cell.imageView.image =  [UIImage imageNamed:@"4.jpg"];

cell.textLabel.text = @"花呗";

}

}

//    cell.imageView.image =  [UIImage imageNamed:@"1.jpg"];

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

if (indexPath.section == 0) {

if (indexPath.row == 0)

{

return 100;

}

}

return 50;

}

上一篇 下一篇

猜你喜欢

热点阅读