IOS彩票第一天基本框架搭建
*****初始化
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// ios6显示状态栏
application.statusBarHidden = NO; // 设置状态栏的颜色
application.statusBarStyle = UIStatusBarStyleLightContent; return YES;
}
*******ILTabBarViewController.m自定义UITabBarController
#import "ILTabBarViewController.h" #import "ILTabBar.h" @interface ILTabBarViewController ()<ILTabBarDelegate> @end @implementation ILTabBarViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. // 创建tabBar
ILTabBar *tabBar = [[ILTabBar alloc] init]; tabBar.delegate = self; tabBar.frame = self.tabBar.bounds; // 因为系统自动隐藏的是系统自带的tabBar
[self.tabBar addSubview:tabBar]; //加上自定义的tabBar NSString *imageName = nil; NSString *selImageName = nil; for (int i = ; i < self.childViewControllers.count; i++) { //遍历自己管理的Controllers imageName = [NSString stringWithFormat:@"TabBar%d",i + ];
selImageName = [NSString stringWithFormat:@"TabBar%dSel",i + ]; // 添加底部按钮
[tabBar addTabBarButtonWithName:imageName selName:selImageName]; } } // 代理方法
- (void)tabBar:(ILTabBar *)tabBar didSelectedIndex:(int)index
{
self.selectedIndex = index; //点击底部按钮切换
}
@end
************ILTabBarViewController.h
#import <UIKit/UIKit.h> @interface ILTabBarViewController : UITabBarController @end
*********ILTabBar.h自定义ILTabBar
#import <UIKit/UIKit.h>
// block作用:保存一段代码,到恰当的时候再去调用 // 如果需要传参数给其他对象,block才需要定义参数
//typedef void(^ILTabBarBlock)(int selectedIndex); @class ILTabBar; @protocol ILTabBarDelegate <NSObject> @optional
- (void)tabBar:(ILTabBar *)tabBar didSelectedIndex:(int)index; @end @interface ILTabBar : UIView //// 相当于小弟
//@property (nonatomic, copy) ILTabBarBlock block; @property (nonatomic, weak) id<ILTabBarDelegate> delegate; // 给外界创建按钮
- (void)addTabBarButtonWithName:(NSString *)name selName:(NSString *)selName; @end
*********ILTabBar.m自定义ILTabBar
#import "ILTabBar.h" #import "ILTabBarButton.h" @interface ILTabBar() @property (nonatomic, weak) UIButton *selectedButton; @end @implementation ILTabBar - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code }
return self;
} // 提供一个方法给外界添加按钮
- (void)addTabBarButtonWithName:(NSString *)name selName:(NSString *)selName
{
// 创建按钮
ILTabBarButton *btn = [ILTabBarButton buttonWithType:UIButtonTypeCustom]; // 设置按钮的图片
[btn setBackgroundImage:[UIImage imageNamed:name] forState:UIControlStateNormal]; [btn setBackgroundImage:[UIImage imageNamed:selName] forState:UIControlStateSelected]; // 监听按钮的点击
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchDown]; [self addSubview:btn]; } // 点击按钮的时候调用
- (void)btnClick:(UIButton *)button
{
// 取消之前选择按钮
_selectedButton.selected = NO;
// 选中当前按钮
button.selected = YES;
// 记录当前选中按钮
_selectedButton = button; // 切换控制器
if ([_delegate respondsToSelector:@selector(tabBar:didSelectedIndex:)]) {
[_delegate tabBar:self didSelectedIndex:button.tag];
} } #warning 设置按钮的位置
- (void)layoutSubviews
{
[super layoutSubviews]; CGFloat btnW = self.bounds.size.width / self.subviews.count;
CGFloat btnH = self.bounds.size.height;
CGFloat btnX = ;
CGFloat btnY = ; // 设置按钮的尺寸
for (int i = ; i < self.subviews.count; i++) {
UIButton *btn = self.subviews[i]; // 绑定角标
btn.tag = i; btnX = i * btnW; btn.frame = CGRectMake(btnX, btnY, btnW, btnH); // 默认选中第一个按钮
if (i == ) {
[self btnClick:btn];
}
} } /*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/ @end
****ILTabBarButton.m自定义UIbutton.m
#import "ILTabBarButton.h" @implementation ILTabBarButton // 取消高亮状态
- (void)setHighlighted:(BOOL)highlighted
{
} @end
***********ILNavigationController.m
#import "ILNavigationController.h" @interface ILNavigationController () @end @implementation ILNavigationController // 第一次使用这个类或者这个类的子类的时候
+ (void)initialize
{
if (self == [ILNavigationController class]) { // 肯定能保证只调用一次
// 获取应用程序中所有的导航条
// 获取所有导航条外观
UINavigationBar *bar = [UINavigationBar appearance]; UIImage *navImage = nil; if (ios7) {
navImage = [UIImage imageNamed:@"NavBar64"];
}else{
navImage = [UIImage imageNamed:@"NavBar"];
}
[bar setBackgroundImage:navImage forBarMetrics:UIBarMetricsDefault]; NSDictionary *dict = @{
NSForegroundColorAttributeName : [UIColor whiteColor],
NSFontAttributeName : [UIFont systemFontOfSize:]
};
[bar setTitleTextAttributes:dict];
}
} - (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%s",__func__); } - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated //跳转隐藏导航栏
{
viewController.hidesBottomBarWhenPushed = YES; return [super pushViewController:viewController animated:animated];
} @end
*****ILNavigationController.h
#import <UIKit/UIKit.h> @interface ILNavigationController : UINavigationController @end
*****我的彩票界面,拉升图片工具 ILLoginViewController.m
#import "ILLoginViewController.h" #import "UIImage+Tool.h" @interface ILLoginViewController ()
@property (weak, nonatomic) IBOutlet UIButton *loginBtn; @end @implementation ILLoginViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. // 设置登录按钮的拉伸好的图片
[_loginBtn setBackgroundImage:[UIImage imageWithResizableImageName:@"RedButton"] forState:UIControlStateNormal]; [_loginBtn setBackgroundImage:[UIImage imageWithResizableImageName:@"RedButtonPressed"] forState:UIControlStateHighlighted];
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
******UIImage+Tool.m
#import "UIImage+Tool.h" @implementation UIImage (Tool) + (instancetype)imageWithResizableImageName:(NSString *)imageName
{
UIImage *image = [UIImage imageNamed:imageName]; image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5]; return image;
} @end
IOS彩票第一天基本框架搭建的更多相关文章
- 基于WebDriverAgent代理服务,实现iOS手机app自动化测试的框架搭建
iOS自动化测试一直使用的appium,iOS系统升级至10.0 Xcode8.0之后, 改用WebDriverAgent代理服务作为server,编写了一套基于WebDriverAgent服务 ap ...
- iOS 新浪微博-1.0框架搭建
项目搭建 1.新建一个微博的项目,去掉屏幕旋转 2.设置屏幕方向-->只有竖向 3.使用代码构建UI,不使用storyboard 4.配置图标AppIcon和LaunchImage 将微博资料的 ...
- IOS开发-基于WebDriverAgent代理服务,实现iOS手机app自动化测试的框架搭建
导引 iOS自动化测试一直使用的appium,iOS系统升级至10.0 Xcode8.0之后,改用WebDriverAgent代理服务作为server,编写了一套基于WebDriverAgent服务 ...
- ThinkPHP框架搭建及常见问题(Apache或MySQL无法启动)----简单的初体验
有一定基础的人勿进,这篇讲的只是零基础入门,都是我刚接触以及我所了解到的人刚开始有疑惑的地方,具体框架介绍会在后面的博客中介绍 这一篇只是为了一个简单的页面显示而介绍的方法,不涉及代码,开发环境,所以 ...
- 【Java EE 学习 69 中】【数据采集系统第一天】【SSH框架搭建】
经过23天的艰苦斗争,终于搞定了数据采集系统~徐培成老师很厉害啊,明明只是用了10天就搞定的项目我却做了23天,还是模仿的...呵呵,算了,总之最后总算是完成了,现在该好好整理该项目了. 第一天的内容 ...
- Struts2+Spring+Hibernate+Jbpm技术实现Oa(Office Automation)办公系统第一天框架搭建
=============编码规范,所有文健,所有页面,所有数据库的数据表都采用UTF-8编码格式,避免乱码:===========开发环境:jdk1.7+tomcat8.0+mysql5.7+ecl ...
- Unity 游戏框架搭建 2019 (九~十二) 第一章小结&第二章简介&第八个示例
第一章小结 为了强化教程的重点,会在合适的时候进行总结与快速复习. 第二章 简介 在第一章我们做了知识库的准备,从而让我们更高效地收集示例. 在第二章,我们就用准备好的导出工具试着收集几个示例,这些示 ...
- Unity 游戏框架搭建 2019 (二十五) 类的第一个作用 与 Obselete 属性
在上一篇我们整理到了第七个示例,我们今天再接着往下整理.我们来看第八个示例: #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; ...
- Unity 游戏框架搭建 2019 (二十六) 第一轮整理完结
昨天呢我们把第八个示例整理完了.整理之后学习了类的第一作用:方法的集合,还有 Obselete 这个 API.并且在进行整理的时候贯彻了我们新的约定和规则:先确保功能有效,再去做变更和删除. 今天我们 ...
随机推荐
- (转)ACM next_permutation函数
转自 stven_king的博客 这是一个求一个排序的下一个排列的函数,可以遍历全排列,要包含头文件<algorithm>下面是以前的笔记 (1) int 类型的next_permuta ...
- JavaScript 之 iframe自适应问题---可以用来实现网页局部刷新
1.HTML <iframe src="index.html" id="iframepage" frameborder="0" scr ...
- DSP using MATLAB 示例Example3.7
上代码: x1 = rand(1,11); x2 = rand(1,11); n = 0:10; alpha = 2; beta = 3; k = 0:500; w = (pi/500)*k; % [ ...
- shell-bash学习01基础、打印、环境变量
基础 终端提示符: username@hostname$; $: 一般用户 #:root用户 运行脚本 Bash执行: * bash script.sh; 直接运行: 脚本开头添加shebang起始: ...
- mac/linux常用命令
文件 创建文件: touch filename 创建目录: mkdir dirname, 创建目录及文件: mkdir -p dir/file 删除文件/目录: rm [-rf] filename 显 ...
- Django学习笔记之一
一.Windows下安装 Django 1.下载安装包解压后放到本地目录如C:\Django-1.7.2 官网地址:https://www.djangoproject.com/download/ 2. ...
- AFNetworking 之于 https 认证
写在开头: 本来这篇内容准备写在AFNetworking到底做了什么?(三)中的,但是因为我想在三中完结这个系列,碍于篇幅所限.并且这一块内容独立性比较强,所以单独拎出来,写成一篇. 本文从源码的角度 ...
- Oralce 常用语句
注:大写代表需要替换掉额 --更新字段名 alter table TABLE rename column COL_OLD to COL_NEW --添加字段名 alter table TABLE ad ...
- 获取iframe的元素并进行操作
获取iframe中的document元素有一下集中方法: 1.getElementById()方法和contentWindow属性: window.onload=function(){ /*必须等待页 ...
- xampp的Apache无法启动解决方法
XAMPP Apache 无法启动原因1(缺少VC运行库): 这个就是我遇到的问题原因,下载安装的XAMPP版本是xampp-win32-1.7.7-VC9,而现有的Windows XP系统又没有安装 ...