POP初步認(rèn)識之POPAnimatableProperty

項目初期因為需要用到動畫展示,便寫了自帶的

[UIView animateWithDuration:2.0 animations:^{

CGRect frame = self.theGreenView.frame;

frame.origin.x+= 200;

self.theGreenView.frame = frame;

} completion:^(BOOL finished) {

}

}];

隨著需求的增加、需要時時的展示控件的X坐標(biāo),上面方法不能滿足需求了。

然后開始集成pop的POPAnimatableProperty進行自定義動畫,目的是改變imageview的x軸坐標(biāo)

官方地址 https://github.com/facebook/pop



POPAnimatableProperty *prop = [POPAnimatableProperty propertyWithName:@"countdown" initializer:^(POPMutableAnimatableProperty *prop) {

prop.writeBlock = ^(id obj, const CGFloat values[]) {

//? ? ? ? ? ? NSLog(@"values==%f",(float)values[0]);

[imageview setLeft:(float)values[0]];

};

//? ? ? ? prop.threshold = 0.01f;

}];

POPBasicAnimation *anBasic = [POPBasicAnimation linearAnimation];? //

anBasic.property = prop;? ? //自定義屬性

anBasic.fromValue = @(imageview.left);? //獲取imageview的初始x軸坐標(biāo) ?

anBasic.toValue = @(value);? //imageview ?的x軸坐標(biāo)

anBasic.duration = 10;? ? //持續(xù)時間

anBasic.beginTime = CACurrentMediaTime() ;? ? //開始時間

[imageview pop_addAnimation:anBasic forKey:@"countdown"];

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容