欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

ios(CoreAnimation核心動畫一)CABasicAnimation動畫 - 新聞資訊 - 云南小程序開發(fā)|云南軟件開發(fā)|云南網站建設-昆明葵宇信息科技有限公司

159-8711-8523

云南網建設/小程序開發(fā)/軟件開發(fā)

知識

不管是網站,軟件還是小程序,都要直接或間接能為您產生價值,我們在追求其視覺表現(xiàn)的同時,更側重于功能的便捷,營銷的便利,運營的高效,讓網站成為營銷工具,讓軟件能切實提升企業(yè)內部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!

您當前位置>首頁 » 新聞資訊 » 技術分享 >

ios(CoreAnimation核心動畫一)CABasicAnimation動畫

發(fā)表時間:2020-10-19

發(fā)布人:葵宇科技

瀏覽次數(shù):64


一、position和anchorPoint
position:用來設置CALayer在父層中的地位,以父層的左上角為原點(0, 0)
anchorPoint(錨點):
稱為“定位點”、“錨點”
決定著CALayer身上的哪個點會在position屬性所指的地位
以本身的左上角為原點(0, 0)
它的x、y取值范圍都是0~1,默認值為(0.5, 0.5)
推薦一個連接:http://www.cnblogs.com/wendingding/p/3800736.html講的異常具體,并且有圖視,默認的錨點為中間點:(0.5,0.5),如不雅從新設置了錨點,運行動畫的時刻會發(fā)明全部控件移動了,所以在設置錨點的時刻須要從新設置position,

 CGPoint oldAnchorPoint = _homeBtn.layer.anchorPoint;
    _homeBtn.layer.anchorPoint =CGPointMake(0.5,0);
     [_homeBtn.layersetPosition:CGPointMake(_homeBtn.layer.position.x + _homeBtn.layer.bounds.size.width * (_homeBtn.layer.anchorPoint.x - oldAnchorPoint.x),_homeBtn.layer.position.y +_homeBtn.layer.bounds.size.height * (_homeBtn.layer.anchorPoint.y - oldAnchorPoint.y))];




二:CABasicAnimation的應用
當你創(chuàng)建一個 CABasicAnimation 時,你須要經由過程-setFromValue 和-setToValue 來指定一個開端值和停止值。 當你增長基本動畫到層中的時刻,它開端運行。
Autoreverses
當你設定則個屬性為 YES 時,在它達到目標地之后,動畫的返回到開端的值,代替了直接跳轉到 開端的值。
Duration
Duration 這個參數(shù)你已經相當熟悉了。它設定開端值到停止值花費的時光。時代會被速度的屬性所影響。 RemovedOnCompletion
這個屬性默認為 YES,那意味著,在指定的時光段完成后,動畫就主動的大年夜層上移除了。這個一般不消。
假如你想要再次用這個動畫時,你須要設定則個屬性為 NO。如許的話,下次你在經由過程-set 辦法設定動畫的屬 性時,它將再次應用你的動畫,而非默認的動畫。
Speed
默認的值為 1.0.這意味著動畫播放按照默認的速度。如不雅你改變┞封個值為 2.0,動畫會用 2 倍的速度播放。 如許的影響就是使持續(xù)時光減半。如不雅你指定的持續(xù)時光為 6 秒,速度為 2.0,動畫就會播放 3 秒鐘---一半的 持續(xù)時光。
BeginTime
這個屬性在組動畫中很有效。它根據父動畫組的持續(xù)時光,指定了開端播放動畫的時光。默認的是 0.0.組 動畫鄙人個段落中評論辯論“Animation Grouping”。
TimeOffset
如不雅一個時光偏移量是被設定,動畫不會真正的可見,直到根據父動畫組中的履行時光獲得的時光都流逝 了。
RepeatCount
    mask
默認的是 0,意味著動畫只會播放一次。如不雅指定一個無窮大年夜的反復次數(shù),應用 1e100f。這個不該該和 repeatDration 屬性一塊應用。
RepeatDuration
這個屬性指定了動畫應當被反復多久。動畫會一向反復,直到設定的時光流逝完。它不該該和 repeatCount 一路應用。 
示例代碼:

    backgroundColor    背景色彩

    
    CGPoint fromPoint = self.testImage.center;
    
    //路徑曲線controlPoint為基準點
    UIBezierPath * movePath = [UIBezierPath bezierPath];
    [movePath moveToPoint:fromPoint];
    CGPoint toPoint = CGPointMake(300, 460);
    [movePath addQuadCurveToPoint:toPoint controlPoint:CGPointMake(300, 0)];
    
    //關鍵幀  設置動畫路徑
    CAKeyframeAnimation * moveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//    moveAnimation.path = movePath.CGPath;
    moveAnimation.values = @[[NSValue valueWithCGPoint:CGPointMake(100, 100)],[NSValue valueWithCGPoint:CGPointMake(100, 300)],[NSValue valueWithCGPoint:CGPointMake(300, 300)],[NSValue valueWithCGPoint:CGPointMake(300, 100)]];
    moveAnimation.removedOnCompletion = YES;
    
    //縮放變更
    CABasicAnimation * scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
    scaleAnimation.fromValue = http://www.sjsjw.com/100/000077MYM008781/[NSValue valueWithCATransform3D:CATransform3DIdentity];
    scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
    scaleAnimation.removedOnCompletion = YES;
    
//    //透明度變更
//    CABasicAnimation * opacityAnimation = [CABasicAnimation animationWithKeyPath:@"alpha"];
//    opacityAnimation.fromValue = [NSNumber numberWithFloat:1.0];
//    opacityAnimation.toValue = [NSNumber numberWithFloat:0.1];
//    opacityAnimation.removedOnCompletion = YES;
    
    //扭轉
    CABasicAnimation * tranformAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    tranformAnimation.fromValue = [NSNumber numberWithFloat:0.f];
    tranformAnimation.toValue = [NSNumber numberWithFloat:M_PI];
    tranformAnimation.cumulative = YES;
    tranformAnimation.removedOnCompletion = YES;
    
    CAAnimationGroup*animaGroup = [CAAnimationGroup animation];
    animaGroup.animations = @[moveAnimation,scaleAnimation,tranformAnimation];
    animaGroup.duration = 2.f;

可以經由過程改變animationWithKeyPath來改更改畫:
 CGPoint oldAnchorPoint =  _homeBtn.layer.anchorPoint;
    _homeBtn.layer.anchorPoint = CGPointMake(0.5, 0);
     [_homeBtn.layer setPosition:CGPointMake(_homeBtn.layer.position.x + _homeBtn.layer.bounds.size.width * (_homeBtn.layer.anchorPoint.x - oldAnchorPoint.x), _homeBtn.layer.position.y + _homeBtn.layer.bounds.size.height * (_homeBtn.layer.anchorPoint.y - oldAnchorPoint.y))];
    
    
    CABasicAnimation*shakeAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    
    shakeAnimation.duration = 0.07;
    shakeAnimation.autoreverses = YES;//當你設定則個屬性為 YES 時,在它達到目標地之后,動畫的返回到開端的值,代替了直接跳轉到 開端的值。
    shakeAnimation.repeatCount = 2;
    shakeAnimation.removedOnCompletion = NO;
    shakeAnimation.fromValue = http://www.sjsjw.com/100/000077MYM008781/[NSNumber  numberWithFloat:-0.05];
    shakeAnimation.toValue = [NSNumber  numberWithFloat:0.05];
    
    [self.homeBtn.layer addAnimation:shakeAnimation forKey:@"shakeAnimation"];

transform.scale = 比例轉換


    transform.scale.x = 闊的比例轉換
    transform.scale.y = 高的比例轉換
    transform.rotation.z = 平面圖的旋轉
    opacity = 透明度
    margin
    zPosition
    cornerRadius    圓角
    borderWidth
    bounds
    contents
    contentsRect
    cornerRadius
    frame
    hidden
    masksToBounds
    opacity
    position
    shadowColor
    shadowOffset
    shadowOpacity
    shadowRadius


58同城客戶端,tabbar的點擊的動畫效不雅,就可以經由過程設置CABasicAnimation屬性來做,小我花了一個小時的時光搞定,證實完全可以實現(xiàn),

相關案例查看更多