[iOS UI进阶 - 2.1] 彩票Demo v1.1

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 设置状态栏样式为白色
application.statusBarHidden = NO;
application.statusBarStyle = UIStatusBarStyleLightContent;
return YES;
}






//
// TitleExtendButton.m
// HelloLottery
//
// Created by hellovoidworld on 15/1/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "TitleExtendButton.h" @interface TitleExtendButton() @property(nonatomic, strong) UIFont *titleFont; @end @implementation TitleExtendButton /** 从文件加载对象就会调用此方法,例如xib和storybard */
- (id)initWithCoder:(NSCoder *)aDecoder {
NSLog(@"从文件加载TitleButton");
if (self = [super initWithCoder:aDecoder]) {
[self initializeButton];
} return self;
} /** 从代码中加载对象就会调用此方法 */
- (instancetype)initWithFrame:(CGRect)frame {
NSLog(@"从代码加载TitleButton");
if (self = [super initWithFrame:frame]) {
[self initializeButton];
} return self;
} - (void) initializeButton {
// 设置font
self.titleFont = [UIFont systemFontOfSize:]; // 暂时先自定义font
self.titleLabel.font = self.titleFont; // 图标居中
[self.imageView setContentMode:UIViewContentModeCenter];
} /** 返回title的frame */
- (CGRect)titleRectForContentRect:(CGRect)contentRect {
CGFloat titleX = ;
CGFloat titleY = ; NSDictionary *attr = @{NSFontAttributeName : self.titleFont};
CGFloat titleWidth; // 只有 iOS7 版本以上才能运行以下代码
if (iOS7) {
// 只有 Xcode5 或以上版本才能识别这段代码
#ifdef __IPHONE_7_0
titleWidth = [self.currentTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attr context:nil].size.width;
#else
titleWidth = [self.currentTitle sizeWithFont:self.titleFont].width;
#endif
} else { // 否则使用旧的API
titleWidth = [self.currentTitle sizeWithFont:self.titleFont].width;
} CGFloat titleHeight = contentRect.size.height; return CGRectMake(titleX, titleY, titleWidth, titleHeight);
} /** 返回image的frame */
- (CGRect)imageRectForContentRect:(CGRect)contentRect {
CGFloat imageWidth = ;
CGFloat imageHeight = contentRect.size.height;
CGFloat imageX = contentRect.size.width - imageWidth;
CGFloat imageY = ;
return CGRectMake(imageX, imageY, imageWidth, imageHeight);
} @end



//
// HVWBuyViewController.m
// HelloLottery
//
// Created by hellovoidworld on 15/1/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWBuyViewController.h"
#import "TitleExtendButton.h" @interface HVWBuyViewController () @property(nonatomic, weak) UIView *popupView; /** 标题点击事件 */
- (IBAction)titleClicked:(TitleExtendButton *)sender; @end @implementation HVWBuyViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /** 延迟初始化弹出view
* (发现放在viewDidLoad的时候,在点击按钮调用的时候pupupView的frame没有被初始化)
*/
- (UIView *)popupView {
if (_popupView == nil) {
// 初始化弹出view
UIView *popupView = [[UIView alloc] init];
CGFloat popupViewX = ;
CGFloat popupViewY = [UIApplication sharedApplication].statusBarFrame.size.height + self.navigationController.navigationBar.frame.size.height;
CGFloat popupViewWidth = self.navigationController.navigationBar.frame.size.width;
CGFloat popupViewHeight = self.view.frame.size.height - popupViewY - self.tabBarController.tabBar.frame.size.height;
popupView.frame = CGRectMake(popupViewX, popupViewY, popupViewWidth, popupViewHeight);
popupView.backgroundColor = [UIColor grayColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
label.text = @"这是全部彩种de弹出内容";
[popupView addSubview:label]; self.popupView = popupView;
NSLog(@"%@", NSStringFromCGRect(self.popupView.frame));
} return _popupView;
} /** 标题点击事件
* 转换箭头方向
* 伸缩内容
*/
- (IBAction)titleClicked:(TitleExtendButton *)sender {
[UIView animateWithDuration:0.5 animations:^{
// 按钮旋转
sender.imageView.transform = CGAffineTransformRotate(sender.imageView.transform, M_PI);
}]; // 弹出view
if (![self.popupView isDescendantOfView:self.view]) {
[self.view addSubview:self.popupView];
} else {
[self.popupView removeFromSuperview];
}
}
@end

#define __IPHONE_2_0 20000
#define __IPHONE_2_1 20100
#define __IPHONE_2_2 20200
#define __IPHONE_3_0 30000
#define __IPHONE_3_1 30100
#define __IPHONE_3_2 30200
#define __IPHONE_4_0 40000
#define __IPHONE_4_1 40100
#define __IPHONE_4_2 40200
#define __IPHONE_4_3 40300
#define __IPHONE_5_0 50000
#define __IPHONE_5_1 50100
#define __IPHONE_6_0 60000
#define __IPHONE_6_1 60100
#define __IPHONE_7_0 70000
#define __IPHONE_7_1 70100
#define __IPHONE_8_0 80000
#define __IPHONE_8_1 80100









//
// UIImage+Extend.m
// HelloLottery
//
// Created by hellovoidworld on 15/1/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "UIImage+Extend.h" @implementation UIImage(Extend) /** 返回一个中心扩展拉伸的图片 */
+ (UIImage *) resizableImage:(NSString *) imageName {
UIImage *image = [UIImage imageNamed:imageName]; // 这个参数决定了左边的保护区域,右边的保护区域为左边+1开始到末端
CGFloat width = image.size.width * 0.5; // 原理同左右保护区域
CGFloat height = image.size.height * 0.5; // 也就是,取中间1x1的区域作为扩展区域
return [image stretchableImageWithLeftCapWidth:width topCapHeight:height];
} @end

//
// HVWLoginViewController.m
// HelloLottery
//
// Created by hellovoidworld on 15/1/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWLoginViewController.h"
#import "UIImage+Extend.h" @interface HVWLoginViewController () /** 登陆按钮 */
@property (weak, nonatomic) IBOutlet UIButton *loginButton; @end @implementation HVWLoginViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. UIImage *normal = [UIImage resizableImage:@"RedButton"];
UIImage *highlighted = [UIImage resizableImage:@"RedButtonPressed"]; [self.loginButton setBackgroundImage:normal forState:UIControlStateNormal];
[self.loginButton setBackgroundImage:highlighted forState:UIControlStateHighlighted];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end



[iOS UI进阶 - 2.1] 彩票Demo v1.1的更多相关文章
- [iOS UI进阶 - 2.4] 彩票Demo v1.4 转盘动画
A.需求 幸运广场界面中有一个幸运转盘,平时能够自动缓缓转动 能够选择星座 点击“开始选号”开速旋转转盘,旋转一定周数 转盘转动速度节奏:开始-慢-块-慢-结束 设置其余的背景和按钮 code s ...
- [iOS UI进阶 - 2.0] 彩票Demo v1.0
A.需求 1.模仿“网易彩票”做出有5个导航页面和相应功能的Demo 2.v1.0 版本搭建基本框架 code source:https://github.com/hellovoidworld/H ...
- [iOS UI进阶 - 2.3] 彩票Demo v1.3
A.需求 真机调试 "关于”模块 存储开关状态 打电话.发短信 应用评分 打开其他应用 cell 在iOS6 和 iOS7的适配 block的循环引用 屏幕适配 code source: ...
- [iOS UI进阶 - 2.2] 彩票Demo v1.2 UICollectionView基本
A.需要掌握的 设计.实现设置界面 cell的封装 UICollectionView的使用 自定义UICollectionView 抽取控制器父类 "帮助"功能 code sour ...
- [iOS UI进阶 - 5.0] 手势解锁Demo
A.需求 1.九宫格手势解锁 2.使用了绘图和手势事件 code source: https://github.com/hellovoidworld/GestureUnlockDemo B ...
- [iOS UI进阶 - 4.0] 涂鸦app Demo
A.需求 1.超简易画图,只有一种画笔 2.清屏功能 3.回退功能 4.保存功能 5.使用了cocos2D code source: https://github.com/hellovoidwor ...
- [iOS UI进阶 - 0] Quiartz2D
A.简介 1. 需要掌握的 drawRect:方法的使用 常见图形的绘制:线条.多边形.圆 绘图状态的设置:文字颜色.线宽等 图形上下文状态的保存与恢复 图形上下文栈 1.基本图形绘制* 线段(线宽. ...
- iOS UI进阶-1.0 Quartz2D
概述 Quartz 2D是一个二维绘图引擎,同时支持iOS和Mac系统.Quartz 2D能完成的工作: 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图像) 读取\生成PDF ...
- UI进阶之--网易彩票手写plist文件,动态创建控制器与tableViewcell
点击右上角设置按钮 点击按钮后发生的事件:1. 控制器的跳转,进入新的控制器.view, 2. 跳转的时候对将要跳转的目标控制的子控件进行了布局.---通过手写plist文件的方式加载 为按钮注册单击 ...
随机推荐
- R语言日期时间函数
Sys.Date( ) returns today's date. date() returns the current date and time.# print today's datetoday ...
- Android开发之TextView实现跑马灯效果
TextView及其子类,当字符内容太长显示不下时可以省略号代替未显示的字符:省略号可以在显示区域的起始,中间,结束位置,或者以跑马灯的方式显示文字(textview的状态为被选中). 其实现只需在x ...
- sort+结构体实现二级排序
之前介绍的sort函数由于其效率较高,使用较为简单让我用起来那叫一个爽,今天再写一篇使用sort+结构体实现二级排序的方法. 还是先想个问题吧,比如我想输入5个同学的名字和身高,然后得到他们身高的降序 ...
- 宏btr_pcur_open_on_user_rec
参考http://wqtn22.iteye.com/blog/1820436 http://blog.jcole.us/2013/01/10/btree-index-structures-in-inn ...
- Swift入门篇-基本类型(1)
博主语文一直都不好(如有什么错别字,请您在下评论)望您谅解,没有上过什么学的 今天遇到了一个很烦的事情是,早上10点钟打开电脑,一直都进入系统(我的系统 mac OS X Yosemite 10.1 ...
- poj 3181 Dollar Dayz
题意:给定一个数p,要求用K种币值分别为1,2,3...K的硬币组成p,问方案数,1,2,2和2,2,1算一种方案即与顺序无关,n <= 1000,k <= 100// 用完全背包做了 这 ...
- oracle 回收站管理
oracle10g,在pl/sql中选中删除后会出现类似:BIN$nJ5JuP9cQmqPaArFei384g==$0的表. 1.查看回收站 select * from user_recyclebin ...
- vs 2005中解决找不到模板项
开始-->所有程序-->Microsoft Visual Studio 2005-->Visual Studio Tools-->Visual Studio 2005 Comm ...
- 20、内存溢出(Out of Memory)
内存引用(释放强引用) Object obj=new Object(); obj = null; 内存引用(使用软引用) 软引用是主要用于内存敏感的高速缓存.在jvm报告内存不足之前会清 除所 ...
- 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(3)
运行ElasticSearch(Running ElasticSearch) 让我们运行我们的第一个实例.转到bin目录并从命令行运行以下命令: ./elasticsearch –f (Linux o ...