仿iPhone自带应用邮件APP的实现

该博客介绍了如何仿照iPhone自带邮件应用,实现类似功能。重点在于使用UIViewController和UITableView的结合,以及添加Toolbar。提供了详细的代码步骤,包括MailBoxTableViewController的添加和Toolbar的实现。文章末尾附带了demo下载链接,供读者实践学习。

1、问题描述

仿iPhone系统应用邮件APP的实现。亮点在于UIViewController+UITableviewController
具体如图所示
邮件APP

2、代码解决

定义
父容器 ViewController
子视图1 MailBoxTableViewController.view
子视图2 UIToolbar

2.1、添加MailBoxTableViewController
    MailBoxTableViewController *mailVC = [[MailBoxTableViewController alloc]initWithStyle:UITableViewStyleGrouped];
    UINavigationController *mailNav = [[UINavigationController alloc]initWithRootViewController:mailVC];
    //在此处设置frame
    mailNav.view.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)-45);
    [self addChildViewController:mailNav];
    [self.view addSubview:mailNav.view];
2.2、添加Toolbar
        UIToolbar *bottombar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.frame)-44, CGRectGetWidth(self.view.frame), 44)];
        NSMutableArray *baritems = [NSMutableArray array];
        UIBarButtonItem *itemleft = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem *itemtitle = [[UIBarButtonItem alloc]initWithTitle:@"刚刚更新" style:UIBarButtonItemStylePlain target:nil action:nil];
        self.itemtitle = itemtitle;
        UIBarButtonItem *itemright = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem *itemnew = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:nil action:nil];
        [baritems addObjectsFromArray:@[itemleft,itemtitle,itemright,itemnew]];
        bottombar.items = baritems;
        [self.view addSubview:bottombar];

3、效果图

邮箱首页 编辑
收件箱 详情页

4、demo下载

提供一个demo,实现了两级页面,后续有时间会持续更新,欢迎关注。
demo下载地址

5、知识点

1、当前视图添加VC
- (void)addChildViewController:(UIViewController *)childController NS_AVAILABLE_IOS(5_0);
2、UIImage以系统蓝色样式展示
- (UIImage *)imageWithRenderingMode:(UIImageRenderingMode)renderingMode NS_AVAILABLE_IOS(7_0);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值