iOS之CAAnimation
UIView, CALayer, CAAnimation,CATransication等;
呈现树模型树以及同步
CAAnimation是加载view.layer.presentationlayer上,而不会更新到view.layer.modellayer;
UIView和UIView的自带layer的属性实际上是对应的是CALayer的modellayer,presentationlayer和modellayer存在同步的关系;
任意时刻如果CAAnimation加到view.layer上,presentationlayer优先从CAAnimation取状态要怎么刷新,动画做完将回归到modellayer的状态;
可以使用CADisplaylink定时器,中取view.layer.presentationlayer的bounds,positon,transform等信息同步到uiview的layer上(modellayer);
12345678910111213141516171819202122232425262728293031323334[CATransaction setA ...
OC之Block
Block用起来很方便,编译过程到底是怎么回事呢?
Block的数据结构12345678910111213struct Block_descriptor_1 { uintptr_t reserved; uintptr_t size;}; struct Block_layout { void *isa; volatile int32_t flags; // contains ref count int32_t reserved; void (*invoke)(void *, ...); struct Block_descriptor_1 *descriptor; // imported variables};
Block编译之后成为一个结构体(实际上就是对象类型因为第一位是*isa),一个函数指针,指向的是编译过程中根据block中代码生成的Imp,最后面的是block中代码持有的变量(相当于对象的成员变量);
Block之变量
block里面对内外部变量会将其对象化成成员变量不添加*__block ...
iOS之Runloop
Runloop,简而言之就是一个死循环用来接受内部和外部事件,定时任务等,和线程有密切的关系;
123456@autoreleasepool { NSLog(@"begin"); int a = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); NSLog(@"end"); return a;}
上面的end永远也不会打印,UIApplicationMain会启动一个死循环;
12345678function loop() { initialize(); do { var message = get_next_message(); process_message(message); } while (message != quit);}
Runloop的创建苹果不允许直接创建Runloop,而是提供了两个方法:
CFRunLoopGet ...