AppDelegate.m 代码

#import "AppDelegate.h"
#import "PigViewController.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];// Override point for customization after application launch.self.window.backgroundColor = [UIColor whiteColor];[self.window makeKeyAndVisible];PigViewController *viewCotroller = [[PigViewController alloc]init];viewCotroller.view.backgroundColor = [UIColor clearColor];//类是用来创建对象UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewCotroller];//创建对象、初始化,添加根视图器self.window.rootViewController = navController;navController.navigationBarHidden = YES;return YES;
}

ViewController.h 头文件

#import <UIKit/UIKit.h>@interface ViewController : UIViewController
@property UITapGestureRecognizer *tap;
@property NSString *name;
@property NSString *firstNb;
@property NSString *audioName;
@property int numble;
- (void)createBgView;
//-(void)Swipe:(id)sender;
@end

第三个页面的界面代码

#import "ViewController.h"
#import "SecondViewController.h"
#import <AudioToolbox/AudioToolbox.h>@interface ViewController ()
{UIImageView *aniImageView;SystemSoundID soundID;UIButton *strokeBtn;UIButton *backBtn;UIButton *voiceBtn;UIButton *practiceBtn;UIImageView *lxImageView;
}@end@implementation ViewController- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {// Custom initialization}return self;
}
- (void)createBgView
{UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 44, 320, 418)];bgImageView.image = [UIImage imageNamed:@"kanaDetailBgImg"];[self.view addSubview:bgImageView];UIImageView *titleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 49)];titleImageView.image = [UIImage imageNamed:@"titleView"];[self.view addSubview:titleImageView];UIImageView *footerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 49, 320, 49)];footerImageView.image = [UIImage imageNamed:@"bottomBg"];[self.view addSubview:footerImageView];
}- (void)createButtons
{//1. 返回按钮backBtn = [UIButton buttonWithType:UIButtonTypeCustom];//设置按钮的图片[backBtn setImage:[UIImage imageNamed:@"backBtn"] forState:UIControlStateNormal];backBtn.frame = CGRectMake(10, 6, 70, 35);[backBtn addTarget:self action:@selector(didBackClicked:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:backBtn];//2. 清除按钮UIButton *clearBtn = [UIButton buttonWithType:UIButtonTypeCustom];//设置按钮的图片[clearBtn setImage:[UIImage imageNamed:@"clearBtn"] forState:UIControlStateNormal];clearBtn.frame = CGRectMake(240, 6, 70, 35);[clearBtn addTarget:self action:@selector(didClearClicked:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:clearBtn];//3. 下面的按钮voiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];voiceBtn.frame = CGRectMake(10, self.view.frame.size.height - 52, 67, 52);[voiceBtn setImage:[UIImage imageNamed:@"pronounceBtn_01"] forState:UIControlStateNormal];//按钮按下去是高亮状态[voiceBtn setImage:[UIImage imageNamed:@"pronounceBtn_02"] forState:UIControlStateHighlighted];[voiceBtn addTarget:self action:@selector(didPlayClicked:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:voiceBtn];//4.笔迅strokeBtn = [UIButton buttonWithType:UIButtonTypeCustom];strokeBtn.frame = CGRectMake(130, self.view.frame.size.height - 52, 67, 52);[strokeBtn setImage:[UIImage imageNamed:@"strokeOrderBtn_01"] forState:UIControlStateNormal];//按钮按下去是高亮状态[strokeBtn setImage:[UIImage imageNamed:@"strokeOrderBtn_02"] forState:UIControlStateHighlighted];[strokeBtn addTarget:self action:@selector(didStrokeBtnClicked:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:strokeBtn];//5.练习practiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];practiceBtn.frame = CGRectMake(240, self.view.frame.size.height - 52, 67, 52);[practiceBtn setImage:[UIImage imageNamed:@"practiceBtn_01"] forState:UIControlStateNormal];//按钮按下去是高亮状态[practiceBtn setImage:[UIImage imageNamed:@"practiceBtn_02"] forState:UIControlStateHighlighted];[practiceBtn addTarget:self action:@selector(didPracticeBtnClicked:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:practiceBtn];}
//动画图片的加载
- (void)createAnimation:(int)n name:(NSString *)nam
{aniImageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 90, 225, 225)];NSMutableArray *array = [[NSMutableArray alloc] init];for (int i = 1; i <= n; i++) {NSString *name = [NSString stringWithFormat:nam, i];UIImage *image = [UIImage imageNamed:name];[array addObject:image];if(i == n) {lxImageView.image = [UIImage imageNamed:name];//动画完后显示写完的图片}}aniImageView.animationImages = array;[self.view addSubview:aniImageView];
}- (void)didBackClicked:(UIButton *)sender
{NSLog(@"%s", __PRETTY_FUNCTION__);//强制清除界面[lxImageView removeFromSuperview];[aniImageView removeFromSuperview];lxImageView = nil;aniImageView = nil;[self.navigationController popViewControllerAnimated:YES];
}- (void)didPlayClicked:(UIButton *)sender
{if (lxImageView != nil) {AudioServicesPlaySystemSound(soundID);NSLog(@"%s", __PRETTY_FUNCTION__);}
}
- (void)didClearClicked:(UIButton *)sender
{[aniImageView stopAnimating];[lxImageView removeFromSuperview];lxImageView = nil;aniImageView = nil;NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)didStrokeBtnClicked:(UIButton *)sender
{NSLog(@"%s", __PRETTY_FUNCTION__);//先有没写的字显示出来才能笔顺if ((aniImageView != nil)|(lxImageView != nil)){if (aniImageView.isAnimating == NO) {[self createAnimation:self.numble name:self.name];aniImageView.animationDuration = 3;aniImageView.animationRepeatCount = 1;[aniImageView startAnimating];}}
}
- (void)didPracticeBtnClicked:(UIButton *)sender
{//lxImageView为空时添加未写的图片if (lxImageView == nil) {lxImageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 90, 225, 225)];lxImageView.image = [UIImage imageNamed:self.firstNb];[self.view addSubview:lxImageView];NSLog(@"%s", __PRETTY_FUNCTION__);}}- (void)viewDidLoad
{[super viewDidLoad];[self createBgView];[self createButtons];NSURL *url = [[NSBundle mainBundle] URLForResource:self.audioName withExtension:@"mp3"];AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID);UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer  alloc] init];swipe.direction = UISwipeGestureRecognizerDirectionRight;[swipe addTarget:self action:@selector(Swipe:)];[self.view addGestureRecognizer:swipe];}-(void)Swipe:(id)sender
{SecondViewController *viewcontroller = [[SecondViewController alloc] init];viewcontroller.view.backgroundColor = [UIColor blackColor];[self.navigationController pushViewController:viewcontroller animated:YES];}- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];
}@end

第三个页面SecondViewController.m,显示由ViewController.传过来的图片数据、播放音频文件

#import "SecondViewController.h"
#import "ViewController.h"@interface SecondViewController ()
{
ViewController *viewCtrl;
}
@end@implementation SecondViewController- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {// Custom initialization}return self;
}- (void)createBgView
{//背景图片的显示UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 49)];bgImageView.image = [UIImage imageNamed:@"titleView"];[self.view addSubview:bgImageView];UIImageView *titleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 49, 320, self.view.frame.size.height -49)];titleImageView.image = [UIImage imageNamed:@"bg_01"];[self.view addSubview:titleImageView];UIImageView *footerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 49, 320, self.view.frame.size.height -49)];footerImageView.image = [UIImage imageNamed:@"bg_01_01"];[self.view addSubview:footerImageView];
}
//封装按钮
- (void)createBtn:(SEL)action frame:(CGRect)frame
{UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];btn.frame = frame;[btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn];}//图片、声音数据的封装
- (void)data:(int)numble name:(NSString *)nm1 aodioName:(NSString *)nm2 firstNb:(NSString *)nm3
{viewCtrl.numble = numble;//图片张数viewCtrl.name = nm1;//动画名字viewCtrl.audioName = nm2;//声音名字viewCtrl.firstNb = nm3;//第一张图片的名字[self.navigationController pushViewController:viewCtrl animated:YES];
}- (void)didBtn1
{NSLog(@"%s", __PRETTY_FUNCTION__);[self data:17 name:@"nu%04d" aodioName:@"042_nu" firstNb:@"nu0001"];
}- (void)didBtn2
{NSLog(@"%s", __PRETTY_FUNCTION__);[self data:15 name:@"na%04d" aodioName:@"040_na" firstNb:@"na0001"];
}- (void)viewDidLoad
{[super viewDidLoad];[self createBgView];//翻页手势,回到首页UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] init];swipe.direction = UISwipeGestureRecognizerDirectionRight;[swipe addTarget:self action:@selector(Swipe:)];[self.view addGestureRecognizer:swipe];viewCtrl = [[ViewController alloc] init];[self createBtn:@selector(didBtn1) frame:CGRectMake(151,230, 50, 30)];//创建按钮[self createBtn:@selector(didBtn2) frame:CGRectMake(49,227, 50, 30)];
}- (void)Swipe:(id)sender
{[self dismissViewControllerAnimated:YES completion:nil];[self.navigationController popViewControllerAnimated:YES];self.navigationController.hidesBarsOnTap = YES;}- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}@end

第一个页面的头文件PigViewController.h

#import <UIKit/UIKit.h>@interface PigViewController : UIViewController
@property UITapGestureRecognizer *tap;
@end

第一个页面显示了一张背景图片,点击可以跳到第二个页面,选择笔画

#import "PigViewController.h"
#import "SecondViewController.h"@interface PigViewController ()@end@implementation PigViewController- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {}return self;
}- (void)viewDidLoad
{[super viewDidLoad];UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];bgImageView.image = [UIImage imageNamed:@"main_Bg"];[self.view addSubview:bgImageView];//创建了一个手势_tap = [[UITapGestureRecognizer alloc] init];[_tap addTarget:self action:@selector(Tap:)];[self.view addGestureRecognizer:_tap];
}- (void)Tap:(id)sender
{
//一个手势,点击可以跳到下一个页面
// self.navigationController.hidesBarsOnTap = YES;SecondViewController *secondCtrl = [[SecondViewController alloc] init];UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:secondCtrl];self.navigationController.toolbarHidden = YES;navCtrl.navigationBarHidden = YES;//弹出一个模态视图[self presentViewController:navCtrl animated:NO completion:nil];
}- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];
}@end

1.点击画面跳到第二个页面

2.实现的两个字  nu、na 点击可跳到笔顺界面

3.返回按钮可回到上一个界面,笔顺写字,练习显示未写字体

一个小小的笔顺程序,按钮太多,暂时实现了两个相关推荐

  1. 编写一个Java应用程序,从键盘读取用户输入两个字符串,并重载3个函数分别实现这两个字符串的拼接、整数相加和浮点数相加。要进行异常处理,对输入的不符合要求的字符串提示给用户,不能使程序崩溃。

    编写一个Java应用程序,从键盘读取用户输入两个字符串,并重载3个函数分别实现这两个字符串的拼接.整数相加和浮点数相加.要进行异常处理,对输入的不符合要求的字符串提示给用户,不能使程序崩溃. pack ...

  2. date日期相减 java_一个小小的Java程序

    如下是一个Java程序实现了从键盘读入出生日期并计算从出生开始过去了多少天/多少周/多少月/多少日. 具体的全部解决思路以及代码.还有代码对应的相关解释已标注与代码中. 如果发现有所问题,还望斧正. ...

  3. 读入两个字符串java_编写一个Java应用程序,从键盘读取用户输入两个字符串,并重载3个strAdd函数...

    分别实现这两个字符串的拼接.整数相加和浮点数相加.要进行异常处理,对输入的不符合要求的字符串提示给用户,不能使程序崩溃.publicclassStrinput{publicstaticvoidmain ...

  4. 我的第一个REST客户端程序!

    Delphi:XE8 看了好几天的资料了,也没有弄出来一个REST程序,尝试了XE8中带的例子,也都没有搞懂.我在网上不断搜索,看是否能够找到适合自己的文章,希望能够做出来一个REST的小例子,万幸, ...

  5. ASP.NET程序设计教程1---第一个ASP.NET程序

    教程以VS2010为开发平台(也可以使用VS2015及以上的IDE),以C#为开发语言,面向初次接触web应用程序设计的读者,从零开始,采用案例的方式,全面.细致的介绍ASP.NET的基础知识和具体应 ...

  6. C#设计一个Windows应用程序,在该程序中首先构造中学生、大学生等派生类,当输入相关数据,单击不同的按钮(“小学生”“中学生”“大学生”)将分别创建不同的学生对象,并输入当前的学生总人数,该学生的

    设计一个Windows应用程序,在该程序中首先构造中学生.大学生等派生类,当输入相关数据,单击不同的按钮("小学生""中学生""大学生")将 ...

  7. 华为计算机变大,华为P20P屏幕太小,一个小小的转换器,秒变电脑模式+超大屏幕...

    华为P20P屏幕太小,一个小小的转换器,秒变电脑模式+超大屏幕 2020-06-06 15:22:50 2点赞 2收藏 4评论 最近写了一篇关于华为手机,如何通过一条数据线连接家里的大屏幕显示器的教程 ...

  8. 图片太大_图片太大?手把手教你如何用java实现一个高质量图片压缩程序

    使用java几十行代码实现一个高质量图片压缩程序,再也不用去自己找网络的压缩程序啦!而且很多网上的工具还有水印或者其他的限制,自己动手写一个简单的应用,是再合适不过了. 一.实现原理 1.声明两个字符 ...

  9. Linux下安装MyEclipse和Tomcat服务器详解,以及我安装过程中所出现的问题以及解决办法,并实现一个web小程序

    1.首先,先要去MyEclipse和Tomcat的官网去下载Linux版的压缩文件,而MyEclipse的中文官网是需要登录并有可能要付钱,大家可以去网上下载,还有就是Tomcat的linux版,这个 ...

  10. 5年前的今天,一个小小的部署错误,让美股最大交易商坠入深渊

    郑昀(订阅号:老兵笔记) 创建于2017/7/29 最后更新于2017/7/31 提纲: 骑士资本集团的大麻烦 毁于冲马桶设计的潜艇 域名轻易被劫持 不可能被攻破的金库被盗 0x01 骑士资本集团的大 ...

最新文章

  1. SAP MM 明明有需求,为啥MRP RUN后没有PR单据产生?
  2. CVPR 2019 | 小样本域适应的目标检测
  3. 使用php操作qq第三方登录
  4. OCM备考 三. Managing Database Availability 之recovery catalog
  5. 什么时候会触发这个策略呢?
  6. gcd(欧几里得算法)
  7. java 迭代器的原理_Java集合框架迭代器Iterator实现原理解析
  8. 【英语学习】【Level 08】U01 Let's Read L3 The classics are always in
  9. 80-30-010-原理-React模式-简介
  10. SVM支持向量机通俗导论(理解SVM的三层境界)
  11. Bailian2765 POJ NOI0113-03 八进制小数【进制】
  12. Spark sql优化
  13. JVM初识之常用参数配置
  14. 戴尔服务器H330阵列卡取消磁盘阵列教程
  15. html 宽度单位,长度单位有哪些?
  16. Deep Ordinal Regression Network for Monocular Depth Estimation
  17. html中颜色取样器工具,PS颜色取样器工具使用方法
  18. 拆弹专家(密码BFS)
  19. java五子棋的重要算法讲解_[Java五子棋小游戏-Ai算法精讲以及实现]-02--高级算法初步...
  20. 从零开始搭建腾讯云服务器

热门文章

  1. plt文件怎么转化为txt文件
  2. 运营级最新修复版苍穹影视(双端千月)
  3. 搭建简单JAVA分布式爬虫系统
  4. linux下重启tomcat命令
  5. 盘点HTML页面跳转的5种方法
  6. 小米笔记本显示器关闭后无法唤醒曲线解决办法
  7. java 把对象转成map_Java对象转换成Map
  8. linux-ab压力测试
  9. html语言制作静态网页,html+css制作的漂亮静态网页
  10. STM32入门开发: 介绍IIC总线、读写AT24C02(EEPROM)(采用模拟时序)