NOTES

hardworking

  • Home
  • Categories
  • Archives
  • Tags
  • About

附近有座教堂,离家也就十分钟,每次远远的看到它,都给我一种奇怪的感觉,在这样一个小城市,尤其显得突兀,怀着好奇的心态,几次都想走进去看看,虽然我很唯物主义,但是对于宗教,对于基督,我一直是抱着尊敬的态度的,

绘图

Posted on 2016-02-07 | In iOS | Visitors

绘图

(一)UIBezierPath

-画出坠落轨迹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- (void)drawRect:(CGRect)rect {
//draw a parabola with one point
UIBezierPath *parabola_path = [UIBezierPath bezierPath];
[parabola_path moveToPoint:CGPointMake(150, 40)];
//加一个受力点
[parabola_path addQuadCurveToPoint:CGPointMake(150, 140) controlPoint:CGPointMake(220, 65)];
[parabola_path moveToPoint:CGPointMake(220, 65)];
//[parabola_path addLineToPoint:CGPointMake(200, 65)];
[[UIColor orangeColor]setStroke];
parabola_path.lineWidth = 10;
[parabola_path stroke];
//draw a parabol with more than one point
UIBezierPath *sline_path = [UIBezierPath bezierPath];
[sline_path moveToPoint:CGPointMake(150, 30)];
//加两个受力点
[sline_path addCurveToPoint:CGPointMake(150, 400) controlPoint1:CGPointMake(80,70) controlPoint2:CGPointMake(230, 160)];
sline_path.lineWidth = 5;
[sline_path stroke];
//sline_path
}
Read more »

hi gitcafe and github

Posted on 2016-01-24 | In life | Visitors

glad to be here with u to learn and to live

Notification

Posted on 2016-01-17 | In iOS | Visitors

NSNotificationCenter

iOS通知中心

- NSNotification类

一个消息对象类,有三个成员变量

1
2
3
@property (readonly, copy) NSString *name;
@property (readonly, retain) id object;
@property (readonly, copy) NSDictionary *userInfo;
  • name:辨别消息对象的唯一标识
  • object:针对某一个对象的消息
  • userInfo:用来传值的一个字典

- NSNotificationCenter类

通知中心,使用单例设计,每个应用程序都会有一个默认的通知中心.用于调度通知的发送和接受


KVO and KVC

Posted on 2016-01-17 | In iOS | Visitors

KVO

key Value Observer它提供一种机制,当指定的对象的属性被修改后,则对象就会接受到通知。简单的说就是每次指定的被观察的对象的属性被修改后,KVO就会自动通知相应的观察者了。

为想要观察的对象添加观察者

1
2
3
4
[object addObserver:observer
forKeyPath:@"frame"
options:NSKeyValueObservingOptionNew
context:nil];
  • object:被观察对象
  • observer:观察对象
  • forKeyPath:需要检测的属性(property的name),如UIViewV的frame,center
  • context:任意类型(一种标识,可用于同时监听不同对象的相同属性?)
    options:
  • options:
1
2
3
4
NSKeyValueObservingOptionNew 更改前的值
NSKeyValueObservingOptionOld 更改后的值
NSKeyValueObservingOptionInitial 初始化的值,一旦注册,立马调用一次,通常会带有新值,不会带有旧值
NSKeyValueObservingOptionPrior 分两次调用,值改变之前和值改变后

添加观察键值变化的处理方法

1
2
3
4
5
6
-(void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary<NSString *,id> *)change
context:(void *)context
}
@end
  • KeyPath:对应forKeyPath
  • object: 被观察者
  • change: 对应相应选项下值的改变(字典类型)可通过对应的key取值,key有new,old,等,可打印输出观察取key值
  • context: 对应context
    Read more »

Animation

Posted on 2016-01-17 | In iOS | Visitors

CA:CoreAnimation动画

属于CALayer层的动画,属于最底层,UIView的底层也是CALayer,UIView是基于CALayer的封装,CALayer具备UIView的所有属性和方法

1. CABasicAnimation

1
2
3
4
5
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
animation.toValue = @(M_PI*2);
animation.duration = 3;
animation.repeatCount = MAXFLOAT;
[_imageView.layer addAnimation:animation forKey:@"animationY"];
  1. key:addAnimation时的key,为自定义动画时的标识,可用于指定动画进行操作,比如删除指定动画
    key获取
  2. KeyPath:系统动画类型标识,用于获得系统动画
    • transform.rotation.x :系统绕x轴旋转动画
    • transform.rotation.y :系统绕y轴旋转动画
    • transform.rotation.z :系统绕z轴旋转动画
    • position : 用于CAKeyframeAnimation做沿“轨迹”运动,见下详细示例

2. CAKeyframeAnimation

CA帧动画,通常可用于按“轨迹”运动,与UIBezierPath结合

1
2
3
4
5
6
7
8
9
10
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:rect];
UIBezierPath *arc = [UIBezierPath bezierPathWithArcCenter:self.view.center radius:120 startAngle:M_PI_2*3 endAngle:M_PI_2*3+M_PI*2 clockwise:YES];
//要沿着路劲跑,必须用关键帧动画
//position:沿着路径动画
CAKeyframeAnimation *moveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//设置动画的路径
moveAnimation.path = arc.CGPath;
moveAnimation.duration = 3;
moveAnimation.repeatCount = MAXFLOAT;
[_imageView.layer addAnimation:moveAnimation forKey:@"runWithPath"];
Read more »

CALayer

Posted on 2016-01-17 | Visitors

CALayer

CAlayer是UIView的底层,通过修改CALayer去做一些界面的修改i

  • 发送通知
  • 接收通知
  • 删除通知
123
JunChuan Shi

JunChuan Shi

学习,生活,记点杂七杂八的东西

27 posts
2 categories
16 tags
RSS
GitHub Weibo Twitter
links
  • rencheng
© 2015 - 2018 JunChuan Shi