美文网首页
影院项目总结

影院项目总结

作者: Mr丶炎 | 来源:发表于2016-07-18 16:44 被阅读54次

三级控制器搭建都大同小异,这次的项目是使用storyboard搭建, 注意下在移除按钮的时候,那个方法应该写在viewWillAppear,而且一定要调用父类方法

界面.png

自定义NavigationController, 注意下设置背景图片和设置字体颜色

#import "WXNavigationController.h"

@interface WXNavigationController ()

@end

@implementation WXNavigationController

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    // 设置背景图片
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg_all-64"] forBarMetrics:UIBarMetricsDefault];
    
    // 设置字体颜色
    NSDictionary *dict = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:15],
                           NSForegroundColorAttributeName : [UIColor whiteColor]};
    [self.navigationBar setTitleTextAttributes:dict];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

自定义TabBarController, 注意下tag值

#import "WXTabBarController.h"
#import "WXTabBarButton.h"

@interface WXTabBarController ()

/** 选中图片 */
@property (nonatomic, strong) UIImageView *selectdImage;

@end

@implementation WXTabBarController

// 这里要注意:因为storyboard创建出来的界面后显示,所有移除的方法应该写在这
- (void)viewWillAppear:(BOOL)animated {
    // 一定要记得调用父类方法
    [super viewWillAppear:animated];
    
    // 1.移除系统上的button
    [self removeSystemBtn];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 2.用自己的button
    [self createTabBarBtn];
    
}

#pragma mark - 移除系统上的button
- (void)removeSystemBtn {
    
    for (UIView *view in self.tabBar.subviews) {
        
        if ([view isKindOfClass:NSClassFromString(@"UITabBarButton")]) {

            [view removeFromSuperview];
            
        }
    }
    
}

#pragma mark - 用自己的button
- (void)createTabBarBtn {
    
    // 1.标题
    NSArray *titles = @[@"首页", @"新闻", @"Top", @"影院", @"更多"];
    
    // 2.图片
    NSArray *imageNames = @[@"movie_home", @"msg_new", @"start_top250", @"icon_cinema", @"more_setting"];
    
    // 3.按钮宽度
    CGFloat btnWidth = [UIScreen mainScreen].bounds.size.width / imageNames.count;
    
    // 4.背景图片
    self.tabBar.backgroundImage = [UIImage imageNamed:@"tab_bg_all"];
    
    // 5.选中图片
    self.selectdImage = [[UIImageView alloc] init];
    self.selectdImage.frame = CGRectMake(0, 0, btnWidth, 49);
    self.selectdImage.image = [UIImage imageNamed:@"selectTabbar_bg_all"];
    [self.tabBar addSubview:self.selectdImage];
    
    for (NSInteger i = 0; i < imageNames.count; i++) {
        
        CGRect btnRect = CGRectMake(i * btnWidth, 0, btnWidth, 49);
        
        WXTabBarButton *button = [[WXTabBarButton alloc] initWithFrame:btnRect withTitle:titles[i] withImage:imageNames[i]];

        
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        button.tag = 1000 + i;

        [self.tabBar addSubview:button];
        
    }

}

#pragma mark - 切换按钮事件
- (void)buttonAction:(UIButton *)button {
    
    self.selectedIndex = button.tag - 1000;
    
    self.selectdImage.center = button.center;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

自定义button继承UIControl, 没什么好讲的,注意下它们的位置

- (instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title withImage:(NSString *)image {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        // 1.创建image
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((self.frame.size.width - 20) / 2, 5, 20, 20)];
        imageView.image = [UIImage imageNamed:image];
        // 图片填充类型
        imageView.contentMode = UIViewContentModeScaleAspectFit;

        // 2.创建label
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - 20, self.bounds.size.width, 20)];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.font = [UIFont systemFontOfSize:12];
        titleLabel.text = title;
        titleLabel.textColor = [UIColor whiteColor];
        
        [self addSubview:imageView];
        [self addSubview:titleLabel];
    }
    
    return self;
}

相关文章

  • 影院项目总结

    三级控制器搭建都大同小异,这次的项目是使用storyboard搭建, 注意下在移除按钮的时候,那个方法应该写在vi...

  • 基于SSM实现的影院订票系统【附源码】(毕设)

    一、项目简介 本项目是一套基于SSM实现的影院订票系统 或 影院售票系统 或 在线电影订票平台,主要针对计算机相关...

  • 项目总结-园区项目总结

    今年是自己进入这个行业的第一年,做的第一个项目,项目时间:4月21日-11月8日。总结一下想到的问题,为日后作参考...

  • 【总结】2017.01.01

    2017.01.01 - 计划 2016.12月总结 2017.01月计划 项目总结 - 实际完成 项目总结一,二...

  • 2019-03-28

    总结总结项目的各种功能,写一下项目流程

  • 全国招商●共享影院项目/简介

    问:什么是共享影院? 答:共享影院,是指将中创投集团高科技影院设备免费投放到酒店客房内,经过专业设计升级为“影院房...

  • iOS 基于 MVC 的项目重构总结

    iOS 基于 MVC 的项目重构总结 iOS 基于 MVC 的项目重构总结

  • (19)外观模式

    1.影院管理项目 组建一个家庭影院: DVD 播放器、投影仪、自动屏幕、环绕立体声、爆米花机,要求完成使用家庭影院...

  • 项目总结

    框架 项目后台采用Springboot+Mybatis的架构,前端使用的Vue框架和ECharts组件,使用Mav...

  • 项目总结

    经过一段时间的学习,智慧社区商超管理系统这个项目结束了,这个项目可分为六个部分: 系统需求分析 系统界面原型设计 ...

网友评论

      本文标题:影院项目总结

      本文链接:https://www.haomeiwen.com/subject/dxapjttx.html