0%

极客学院充值月度 VIP,学习 iOS 视频,感觉他们的知识体系图和实战路径图很不错,按照一个大纲去学习的。

今天按照视频指导:制作汤姆猫小游戏,完成以下 DEMO。

其中发现我写代码中遇到很多小问题,google 就有答案的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// ViewController.m
// Tomcat Game DEMO
//
// Created by Will on 5/24/15.
// Copyright (c) 2015 gewill.org. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *tomImageView;

@end

@implementation ViewController



- (IBAction)touchHeadOnHead:(UIButton *)sender {
[self tomAnimateWith:@"knockout" imageCount:81];


}
- (IBAction)touchEat:(UIButton *)sender {
[self tomAnimateWith:@"eat" imageCount:40];
}
- (IBAction)touchPie:(UIButton *)sender {
[self tomAnimateWith:@"pie" imageCount:24];
}
- (IBAction)touchScratch:(UIButton *)sender {
[self tomAnimateWith:@"scratch" imageCount:56];
}
- (IBAction)TouchDrink:(UIButton *)sender {
[self tomAnimateWith:@"drink" imageCount:81];
}
- (IBAction)touchCymbal:(UIButton *)sender {
[self tomAnimateWith:@"symbal" imageCount:13];
}
- (IBAction)touchStomach:(UIButton *)sender {
[self tomAnimateWith:@"stomach" imageCount:34];

}
- (IBAction)touchFootLeft:(UIButton *)sender {
[self tomAnimateWith:@"footLeft" imageCount:30];
}
- (IBAction)touchFootRight:(UIButton *)sender {
[self tomAnimateWith:@"footRight" imageCount:30];
}
- (IBAction)touchAngry:(UIButton *)sender {
[self tomAnimateWith:@"angry" imageCount:26];
}

#pragma mark - 动画执行方法
- (void)tomAnimateWith:(NSString *)fileName imageCount:(NSInteger)imageCount{
// 0. 判断是否正在执行动画
if (self.tomImageView.isAnimating) {
return;
}

// 1. 创建图片数组
NSMutableArray *tomImages = [NSMutableArray array];

for (int i = 0; i < imageCount; i++) {
NSString *imageName = [NSString stringWithFormat:@"%@_%02d.jpg", fileName, i];
NSString *path =[[NSBundle mainBundle] pathForResource:imageName ofType:nil];
UIImage *image = [UIImage imageWithContentsOfFile:path];
[tomImages addObject:image ];
}

// 2. 设置动画过程
[self.tomImageView setAnimationImages:tomImages];
[self.tomImageView setAnimationDuration:self.tomImageView.animationImages.count * 0.1];
[self.tomImageView setAnimationRepeatCount:1];
[self.tomImageView startAnimating];

}



- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

一个简单地计算器,可以加减乘除,除法还有问题,待解决。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// ViewController.swift
// Simple Calculator
//
// Created by Will on 5/24/15.
// Copyright (c) 2015 gewill.org. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
@IBOutlet weak var text1: UITextField!


@IBOutlet weak var text2: UITextField!
@IBOutlet weak var result: UITextField!

@IBAction func BeZero(sender: AnyObject) {
self.result.text = "0"
self.text1.text = " "
self.text2.text = " "

}
@IBAction func plus(sender: AnyObject) {
// 三目运算符简洁,但是没有 if 逻辑清晰。
var num1 = self.text1.text.isEmpty ? 0 : self.text1.text.toInt()
var num2 = self.text2.text.isEmpty ? 0 : self.text2.text.toInt()


var resultNum:Double = Double(num1!) + Double(num2!)
println(resultNum)

self.result.text = "\(resultNum)"

self.text1.resignFirstResponder()
self.text2.resignFirstResponder()


}
@IBAction func minus(sender: AnyObject) {
// 三目运算符简洁,但是没有 if 逻辑清晰。
var num1 = self.text1.text.isEmpty ? 0 : self.text1.text.toInt()
var num2 = self.text2.text.isEmpty ? 0 : self.text2.text.toInt()


var resultNum = num1! - num2!

self.result.text = "\(resultNum)"

self.text1.resignFirstResponder()
self.text2.resignFirstResponder()

}
@IBAction func multiply(sender: AnyObject) {
// 三目运算符简洁,但是没有 if 逻辑清晰。
var num1 = self.text1.text.isEmpty ? 0 : self.text1.text.toInt()
var num2 = self.text2.text.isEmpty ? 0 : self.text2.text.toInt()


var resultNum = num1! * num2!

self.result.text = "\(resultNum)"

self.text1.resignFirstResponder()
self.text2.resignFirstResponder()

}
@IBAction func division(sender: AnyObject) {
// 三目运算符简洁,但是没有 if 逻辑清晰。
var num1 = self.text1.text.isEmpty ? 0 : self.text1.text.toInt()
var num2 = self.text2.text.isEmpty ? 0 : self.text2.text.toInt()


var resultNum = num1! / num2!

self.result.text = "\(resultNum)"

self.text1.resignFirstResponder()
self.text2.resignFirstResponder()

}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}



Imgur
Imgur

如何成为一名优秀的设计师:罗子雄
@TEDx Chongqing

##入门

##提高

  • 看 v2.0

  • 做 v2.0:模仿、参赛

    • 借鉴
    • 改进
    • 组合
  • 想 v2.0

虽然目录已经整理很好,但是为了多说话,我就讲讲的感受。 最近接触 iOS 开发需要做 logo 和 UI 设计,才开始接触设计方面,发现是一门创造美的过程。罗子雄说的方法很平白,也易于操作。但于我这般没有自律和执行力的人,报班学习最好,定闹钟次之,

自动打开我的网站 gewill.org 的 app。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// ViewController.swift
// Open gewill.org
//
// Created by Will on 5/21/15.
// Copyright (c) 2015 gewill.org. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
UIApplication.sharedApplication().openURL(NSURL(string: "http://gewill.org")!)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}


Github pages is too slowly, today I use gitcafe host my website by default. And resolve github to overseas users.

Read more »

1
open -a application ~/file

也可编辑vim ~/.zshrc关联软件:

1
2
3
4
5
6
7

alias ty='open -a typora'
alias -s md='open -a typora'
alias -s markdown='open -a typora'

alias showt='defaults write com.apple.finder AppleShowAllFiles TRUE'
alias showf='defaults write com.apple.finder AppleShowAllFiles FALSE'

即刻实现输入文件名打开文件:

1
~/Readme.md