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.并且在进行整理的时候贯彻了我们新的约定和规则:先确保功能有效,再去做变更和删除. 今天我们 ...
随机推荐
- hdu1160 LIS变形
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1160 题意:两个子序列 一个是升序,一个是降序,求最长的子序列是多长,并输出路径.(答案不 ...
- Codeforces Round #375 (Div. 2) - A
题目链接:http://codeforces.com/contest/723/problem/A 题意:在一维坐标下有3个人(坐标点).他们想选一个点使得他们3个到这个点的距离之和最小. 思路:水题. ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
- 仓库、超市、服装、食品、批发零售手持打印PDA开单器-现场无线开单扫描 无线传输电脑
深圳浩瀚技是一家主要从事手持数据终端硬件.软件研究.销售服务为一体的高新企业公司.公司主要销售进销存等无线开单系统.工业级手持PDA,安卓数据采集器,RFID阅读器等设备.我们秉承“诚信.敏捷.繁荣” ...
- PHP 下载简历
下载简历:先生成html模版,然后在下载转化为word格式: 获取数据方法: 先获取数据,然后开启缓存,写入数据,关闭缓存:然后下载成word: /** * 下载简历--简单 * @author La ...
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)
暴力 A - Orchestra import java.io.*; import java.util.*; public class Main { public static void main(S ...
- Codeforces Round #337 (Div. 2)
水 A - Pasha and Stick #include <bits/stdc++.h> using namespace std; typedef long long ll; cons ...
- URAL1018 Binary Apple Tree(树形DP)
题目大概说一棵n结点二叉苹果树,n-1个分支,每个分支各有苹果,1是根,要删掉若干个分支,保留q个分支,问最多能保留几个苹果. 挺简单的树形DP,因为是二叉树,都不需要树上背包什么的. dp[u][k ...
- 百度地图API使用记录
用户数据图层的总教程: 就是把用户数据存到LBS云里面,应用从云里面读数据 http://developer.baidu.com/map/jsdevelop-9.htm 上传数据的地方: http:/ ...
- BZOJ3161 : 孤舟蓑笠翁
显然求出每个点到所有关键点的最短路和次短路即可,答案就是每个关键点的次短路. 设$f[i][j][0]$表示左手在$i$,右手在$j$的解,$f[i][j][1]$表示左手在$i$,右手在$j$,且左 ...