tom猫的UI
来源:互联网 发布:条码数据采集 编辑:程序博客网 时间:2024/05/06 14:13
今天我学习了ios中的UIButton属性和UIImageView属性的相关用法,做了一个简易的tom猫UI程序。
1. 搭建UI界面
2.实现按钮监听
3.代码重构
3.性能优化
//// GJJViewController.h// tom猫//// Created by apple on 14-4-25.// Copyright (c) 2014年 apple. All rights reserved.//#import <UIKit/UIKit.h>@interface GJJViewController : UIViewController@property (weak, nonatomic) IBOutlet UIImageView *tomCat;// tom猫的行为- (IBAction)tomCatBehaviour:(UIButton *)sender;@end
//// GJJViewController.m// tom猫//// Created by apple on 14-4-25.// Copyright (c) 2014年 apple. All rights reserved.//#import "GJJViewController.h"#define kPlayerTime 0.1#define kPlayerCount 1#define kDocumentName @"tom"#define kDocumentLastName @"plist"@interface GJJViewController (){ // 将tom猫程序的播放图片名称和数量抽取到tom.plist文件中 NSDictionary *_tomDict;}@end@implementation GJJViewController- (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib. // 获得tom.plist文件的全路径 NSBundle *bundle = [NSBundle mainBundle]; // 获得全路径 NSString *name = [bundle pathForResource:kDocumentName ofType:kDocumentLastName]; // 获得文件中的字典 _tomDict = [NSDictionary dictionaryWithContentsOfFile:name]; }- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}#pragma mark tom猫动画- (void)tomCatBehaviourAnimating:(NSString *)name withImageCount:(int)count { // 通过bundle拿到图片的全路径 NSBundle *bundle = [NSBundle mainBundle]; // 定义可变数组来存储图片 NSMutableArray *tomAnimationImages = [[NSMutableArray alloc] init]; for (int i = 0; i < count; i ++) { // 图片名称 NSString *tomImageName = [NSString stringWithFormat:@"%@_%02d.jpg", name, i]; // 获得全路径 NSString *tomImageNamePath = [bundle pathForResource:tomImageName ofType:nil]; // 通过图片全路径来获得图片 UIImage *tomImage = [[UIImage alloc] initWithContentsOfFile:tomImageNamePath]; // 添加图片 [tomAnimationImages addObject:tomImage]; } // 设置播放动画的图片 _tomCat.animationImages = tomAnimationImages; // 设置播放动画的时间 _tomCat.animationDuration = kPlayerTime * count; // 设置播放动画的次数 _tomCat.animationRepeatCount = kPlayerCount; // 开启动画 [_tomCat startAnimating];}#pragma mark tom猫的行为- (IBAction)tomCatBehaviour:(UIButton *)sender { if ( [_tomCat isAnimating] ) return; // 获得普通状态下按钮的名称 NSString *name = [sender titleForState:UIControlStateNormal]; // 获得图片播放的张数 int count = [_tomDict[name] intValue]; // 播放动画 [self tomCatBehaviourAnimating:name withImageCount:count]; }@end
0 0
- tom猫的UI
- TOM猫的简单实现
- 会说话的tom猫
- 猫猫学IOS(四)UI之半小时搞定Tom猫
- Tom猫
- TOM猫
- Tom-猫
- IOS初体验-Tom猫的开发
- iOS界面--Tom猫的实现
- iOS模拟Tom猫的简单界面
- AJ学IOS(04)UI之半小时搞定Tom猫
- iOS开发 - 第01篇 - UI基础 - 02 - 图片浏览&TOM猫
- Tom的UNLOAD程序
- 霸道的TOM SKYPE
- Tom的烦恼(normal)
- TOM大师的show_space
- Tom的生日礼物
- 165,TOM猫源代码
- 社区氛围不是很浓厚,多是一群老领导上台讲话
- android 单元测试
- 内存中数据的存储类型、作用域
- Qt5 基于TCP传输的发送/接收文件服务器(支持多客户端)
- c++-转换构造函数
- tom猫的UI
- mysql 查看表结构
- 内存管理之程序内存分布
- Android 仿美团网,大众点评购买框悬浮效果之修改版
- 算法实验 二叉树的创建和前序-中序-后序-层次 遍历
- 谭晓生将在第六届云计算大会“云计算安全论坛”发表演讲
- 自定义View--Label + TextField
- 360网站卫士每秒拦截6.8万次黑客攻击
- Linux/UNIX线程(1)