AppDelegate.m
#import "AppDelegate.h"
//引入VC控制器 头文件
#import "ViewController.h"
#import "WXApi.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
// Override point for customization after application launch.
//设置VC为跟控制器
self.window.rootViewController=[[UINavigationController alloc]initWithRootViewController:[ViewController new]];
[WXApi registerApp:@"wx537cf8aac45b25df"];
return YES;
}
ViewController.m
#import "ViewController.h"
#import "twoViewController.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
{
//创建表格
UITableView *tbv;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//设置标题
self.title=@"消息";
//设置标题文字颜色
self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18]};
//设置Navbar背景颜色
self.navigationController.navigationBar.barTintColor=[UIColor blackColor];
//表格初始化
tbv=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
//表格代理
tbv.delegate=self;
//表格数据源
tbv.dataSource=self;
//设置表格背景颜色
tbv.backgroundColor=[UIColor blackColor];
//将表格->添加到视图上
[self.view addSubview:tbv];
//设置一个 View 层
UIView*V1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 44)];
UIButton*Btn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 80, 44)];
[V1addSubview:Btn];
//设置按钮标题颜色
[BtnsetTitle:@"联系人 >" forState:UIControlStateNormal];
//设置 Navbar 右侧 按钮
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:V1];
//设置底部
UIImageView *bottomview=[[UIImageView alloc]initWithFrame:CGRectMake(-2, self.view.frame.size.height-48, self.view.frame.size.width+6, 50)];
bottomview.image=[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.50.41"];
// bottomview.backgroundColor=[UIColor redColor];
[self.viewaddSubview:bottomview];
}
#pragma mark --- 表格【返回分区】方法 ---
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
{
return2;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
if(section==0) {
return1;
}
else
{
return3;
}
}
#pragma mark --- 表格【数据内容】方法 ---
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
//初始化cell
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"1"];
//单元格 cell 复用
if(!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"1"];
}
// 设置表格背景色 为黑色
cell.backgroundColor=[UIColorcolorWithRed:255/255.0green:255/255.0blue:255/255.0alpha:0.2];
if(indexPath.section==0) {
//设置表格行高
tbv.rowHeight=150;
UIView *BtnV1=[[UIButton alloc]initWithFrame:CGRectMake(10, 10, (self.view.frame.size.width)-20, 150-20)];
BtnV1.backgroundColor=[UIColor clearColor];
[celladdSubview:BtnV1];
#pragma mark --- 设置表格 内4个icon ---
//第一个
UIButton*btn1=[[UIButton alloc]initWithFrame:CGRectMake(20, 40, 60, 60)];
[btn1setImage:[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.26.36"] forState:UIControlStateNormal];
UILabel*lab1=[[UILabel alloc]initWithFrame:CGRectMake(35, 100, 100, 25)];
lab1.text=@"粉丝";
[btn1addTarget:self action:@selector(blick) forControlEvents:UIControlEventTouchUpInside];
lab1.textColor=[UIColor whiteColor];
[celladdSubview:lab1];
// btn1.backgroundColor=[UIColor whiteColor];
[celladdSubview:btn1];
//第二个
UIButton*btn2=[[UIButton alloc]initWithFrame:CGRectMake(20+60+30, 40, 60, 60)];
[btn2setImage:[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.26.41"] forState:UIControlStateNormal];
UILabel*lab2=[[UILabelalloc]initWithFrame:CGRectMake(35*3+20, 100, 100, 25)];
lab2.text=@"点赞";
lab2.textColor=[UIColor whiteColor];
[celladdSubview:lab2];
// btn2.backgroundColor=[UIColor whiteColor];
[celladdSubview:btn2];
//第三个
UIButton*btn3=[[UIButtonalloc]initWithFrame:CGRectMake((20+60+30+30+60), 40, 60, 60)];
[btn3setImage:[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.26.47"] forState:UIControlStateNormal];
UILabel*lab3=[[UILabelalloc]initWithFrame:CGRectMake(35*6+5, 100, 100, 25)];
lab3.text=@"我的";
lab3.textColor=[UIColor whiteColor];
[celladdSubview:lab3];
// btn3.backgroundColor=[UIColor whiteColor];
[celladdSubview:btn3];
//第四个
UIButton*btn4=[[UIButtonalloc]initWithFrame:CGRectMake((20+60+30+30+60+90), 40, 60, 60)];
[btn4setImage:[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.26.53"] forState:UIControlStateNormal];
btn4.backgroundColor=[UIColor whiteColor];
UILabel*lab4=[[UILabelalloc]initWithFrame:CGRectMake(35*8+25, 100, 100, 25)];
lab4.text=@"评论";
lab4.textColor=[UIColor whiteColor];
[celladdSubview:lab4];
[celladdSubview:btn4];
}
else
{
tbv.rowHeight=75;
UIImageView *imgv=[[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 35, 35)];
imgv.image=[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.45.56"];
[celladdSubview:imgv];
//主标题
UILabel *lab1=[[UILabel alloc]initWithFrame:CGRectMake(70, 10, 200, 40)];
lab1.text=@"资讯助手";
[celladdSubview:lab1];
//副标题
UILabel *lab2=[[UILabel alloc]initWithFrame:CGRectMake(70, 30, 200, 40)];
lab2.text=@"出国游前必学的咖啡叫法";
lab2.textColor=[UIColor grayColor];
[celladdSubview:lab2];
}
returncell;
}
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0)];
UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 0)];
// view.backgroundColor = [UIColor Color];
lable.text=@"dfkjakj";
[viewaddSubview:lable];
returnview;
}
-(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0)];
UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 0)];
// view.backgroundColor = [UIColor Color];
lable.text=@"dfkjakj";
[viewaddSubview:lable];
returnview;
}
//实现粉丝点击 跳转
-(void)blick
{
twoViewController*two=[twoViewController new];
[self presentViewController:two animated:YES completion:nil];
}
@end
two.m
#import "twoViewController.h"
#import "pengyouquanViewController.h"
#import "weixinViewController.h"
#import "WXApi.h"
@interface twoViewController ()
@end
@implementationtwoViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor colorWithRed:185/255.0 green:220/255.0 blue:150/255.0 alpha:1];
UIImageView*view=[[UIImageView alloc]initWithFrame:CGRectMake(-2,-2, self.view.frame.size.width+4, self.view.frame.size.height+4)];
view.image=[UIImage imageNamed:@"屏幕快照 2018-10-26 上午9.57.41"];
[self.view addSubview:view];
UIButton*btn=[[UIButton alloc]initWithFrame:CGRectMake(0,self.view.frame.size.height-40, self.view.frame.size.width, 40)];
btn.backgroundColor=[UIColor clearColor];
[btnaddTarget:self action:@selector(fanhui) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
//朋友圈分享按钮
UIButton*btn1=[[UIButton alloc]initWithFrame:CGRectMake(90,430, 50, 100)];
btn1.backgroundColor=[UIColor clearColor];
[self.view addSubview:btn1];
[btn1addTarget:self action:@selector(pengyouquan) forControlEvents:UIControlEventTouchUpInside];
//微信分享按钮
UIButton*btn2=[[UIButton alloc]initWithFrame:CGRectMake(160,430, 50, 100)];
btn2.backgroundColor=[UIColor clearColor];
[self.view addSubview:btn2];
[btn2addTarget:self action:@selector(weixin) forControlEvents:UIControlEventTouchUpInside];
}
-(void)fanhui{
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)pengyouquan
{
// 文字分享
SendMessageToWXReq *rep =[[SendMessageToWXReq alloc] init];
rep.text=@"分享内容";
rep.bText=YES;
rep.scene=WXSceneSession;
[WXApi sendReq:rep];
// pengyouquanViewController*pengyou=[pengyouquanViewController new];
// [self presentViewController:pengyou animated:YES completion:nil];
}
-(void)weixin
{
weixinViewController *weixin=[weixinViewController new];
[self presentViewController:weixin animated:YES completion:nil];
}
weixinViewController.m
#import "weixinViewController.h"
#import "ViewController.h"
@interface weixinViewController ()
@end
@implementationweixinViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIImageView*view=[[UIImageView alloc]initWithFrame:CGRectMake(-2,-2, self.view.frame.size.width+4, self.view.frame.size.height+4)];
view.image=[UIImage imageNamed:@"B6409328A164CFF8054B5D2288D4D487"];
[self.view addSubview:view];
self.view.backgroundColor=[UIColor clearColor];
UIButton*btn=[[UIButton alloc]initWithFrame:CGRectMake((self.view.frame.size.width/2)-100,(self.view.frame.size.height/2)+90, self.view.frame.size.width-100, 40)];
btn.backgroundColor=[UIColor clearColor];
[btnaddTarget:self action:@selector(fanhui) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
-(void)fanhui{
[self dismissViewControllerAnimated:YES completion:nil];
}