AppDelegate里面的內(nèi)容
#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 {
???
??? // 創(chuàng)建控制器
??? FirstViewController *fVC = [[FirstViewController alloc]init];
??? // 創(chuàng)建導(dǎo)航控制器
??? UINavigationController *fNav = [[UINavigationController alloc]initWithRootViewController:fVC];
??? // 創(chuàng)建標(biāo)簽控制器
??? UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"首頁" image:[UIImage imageNamed:@"DD"] selectedImage:[UIImage imageNamed:@"DD_H"]];
??? // 把控制器賦給導(dǎo)航控制器
??? fNav.tabBarItem = item1;
???
???
??? // 創(chuàng)建控制器
??? SecViewController *sVC = [[SecViewController alloc]init];
??? // 創(chuàng)建導(dǎo)航控制器
??? UINavigationController *sNav = [[UINavigationController alloc]initWithRootViewController:sVC];
??? // 創(chuàng)建標(biāo)簽控制器
??? UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"口碑" image:[UIImage imageNamed:@"dongTai"] selectedImage:[UIImage imageNamed:@"dongTai_H"]];
??? // 把控制器賦給導(dǎo)航控制器
??? sNav.tabBarItem = item2;
??? // 創(chuàng)建控制器
??? ThreeViewController *tVC = [[ThreeViewController alloc]init];
??? // 創(chuàng)建導(dǎo)航控制器
??? UINavigationController *tNav = [[UINavigationController alloc]initWithRootViewController:tVC];
??? // 創(chuàng)建標(biāo)簽控制器
??? UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"朋友" image:[UIImage imageNamed:@"DD"] selectedImage:[UIImage imageNamed:@"DD_H"]];
??? // 把控制器賦給導(dǎo)航控制器
??? tNav.tabBarItem = item3;
??? // 創(chuàng)建控制器
??? FourViewController *FVC = [[FourViewController alloc]init];
??? // 創(chuàng)建導(dǎo)航控制器
??? UINavigationController *FNav = [[UINavigationController alloc]initWithRootViewController:FVC];
??? // 創(chuàng)建標(biāo)簽控制器
??? UITabBarItem *item4 = [[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"dongTai"] selectedImage:[UIImage imageNamed:@"dongTai_H"]];
??? // 把控制器賦給導(dǎo)航控制器
??? 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)];
??????? // 設(shè)置圓角屬性
??????? _headImage.layer.cornerRadius = 20;
??????? _headImage.layer.masksToBounds = YES;
??? }
??? return _headImage;
}
- (UILabel *)titLabel
{
??? if (!_titLabel) {
??????? // 初始化label
??????? _titLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 5, 100, 30)];
??????? // 設(shè)置Label的字體
??????? _titLabel.font = [UIFont systemFontOfSize:16];
???????
??? }
??? return _titLabel;
}
- (UILabel *)subLabel
{
??? if (!_subLabel) {
??????? // 初始化label
??????? _subLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 30, 350, 20)];
??????? // 設(shè)置label的字體
??????? _subLabel.font = [UIFont systemFontOfSize:12];
??? }
??? return _subLabel;
}
- (UILabel *)timeLabel
{
??? if (!_timeLabel) {
??????? // 初始化Label
??????? _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(350, 10, 40, 40)];
??????? // 設(shè)置字體
??????? _timeLabel.font = [UIFont systemFontOfSize:12];
??? }
??? return _timeLabel;
}
// 第三個(gè)控制器里面的
#import "ThreeViewController.h"#import "FriendTableViewCell.h"@interface ThreeViewController (){
UITableView *_tableView;
NSMutableDictionary *data;
}
@end
@implementation ThreeViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"朋友";
// 設(shè)置導(dǎo)航控制器的背景顏色
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:25/255.0 green:108/255.0 blue:198/255.0 alpha:1.0];
// 設(shè)置背景顏色
self.view.backgroundColor = [UIColor whiteColor];
// 初始化TableView
_tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 70, self.view.frame.size.width, 300) style:UITableViewStylePlain];
// 設(shè)置代理
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = 60;
// 將TableView添加到視圖上
[self.view addSubview:_tableView];
}
// 設(shè)置行數(shù)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
// 數(shù)據(jù)源方法
- (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 = @"生活號(hào)";
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;
}
//第四個(gè)控制器里面的
@interface FourViewController (){
UITableView *_tableView;
NSArray *_imageArr;
NSArray *_titleArr;
}
@end
@implementation FourViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// 設(shè)置導(dǎo)航控制器的背景顏色
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];
// 設(shè)置代理
_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 = @"未設(shè)置昵稱";
[cell.contentView addSubview:titLabel];
}
if (indexPath.row == 1) {
cell.imageView.image = [UIImage imageNamed:@"2.jpg"];
cell.textLabel.text = @"螞蟻會(huì)員";
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 = @"總資產(chǎn)";
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 = @"螞蟻財(cái)富";
}
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 = @"保險(xiǎn)服務(wù)";
}
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;
}