사용하여 중첩 된 애니메이션 세트를 수행하려고 UIView.animateWithDuration
하지만 사용 하는 클로저 반환 매개 변수에 관계없이 예외가 발생하는 것 같습니다.
'(NSTimeInterval, delay : NSTimeInterval, options : UIViewAnimationOptions, animations : ()-> Void, complete : (Bool)-> Void)'유형의 인수 목록으로 'animateWithDuration'을 호출 할 수 없습니다.
이것은 불쾌한 기능입니다.
func animateLikeButton(button: UIButton?)
{
button?.userInteractionEnabled = false;
let pixelsToScale = 9.0;
let pixelsToShrink = 4.0;
let buttonFrame = button?.frame
// Big
let scaleOriginX = Double(buttonFrame!.minX) - pixelsToScale / 2.0
let scaleOriginY = Double(buttonFrame!.minY) - pixelsToScale / 2.0
let scaleSizeX = Double(buttonFrame!.width) + pixelsToScale
let scaleSizeY = Double(buttonFrame!.height) + pixelsToScale
// Small
let shrinkOriginX = Double(buttonFrame!.minX) + pixelsToScale / 2.0
let shrinkOriginY = Double(buttonFrame!.minY) + pixelsToScale / 2.0
let shrinkSizeX = Double(buttonFrame!.width) - pixelsToScale
let shrinkSizeY = Double(buttonFrame!.height) - pixelsToScale
UIView.animateWithDuration(NSTimeInterval(0.4), delay:NSTimeInterval(0), options: UIViewAnimationOptions.CurveEaseInOut,
animations:
{
() -> Void in
button?.frame = CGRect(origin: CGPoint(x: scaleOriginX, y: scaleOriginY), size: CGSize(width: scaleSizeX, height: scaleSizeY))
},
completion:
{
(finished: Bool) -> Void in
UIView.animateWithDuration(NSTimeInterval(0.2), delay:NSTimeInterval(0.1), options: UIViewAnimationOptions.CurveEaseInOut,
animations:
{
() -> Void in
button?.frame = CGRect(origin: CGPoint(x: shrinkOriginX, y: shrinkOriginY), size: CGSize(width: shrinkSizeX, height: shrinkSizeY))
},
completion:
{
(finished: Bool) -> Void in
UIView.animateWithDuration(NSTimeInterval(0.2), delay:NSTimeInterval(0), options: UIViewAnimationOptions.CurveEaseInOut,
animations:
{
() -> Void in
button?.frame = buttonFrame!
},
completion:
{
(finished: Bool) -> Void in
button?.userInteractionEnabled = true
}
)
}
)
}
)
}
솔직히 말해서 나는 클로저 리턴 매개 변수 (옵션 유무에 관계없이)에 대해 가능한 모든 조합을 시도했지만 운이 없었다. 예를 들면 :
(_) -> Void in
(finished: Bool) in
(finished: Bool) -> bool in
finished in
_ in
내가 시도해 볼 제안이 있습니까?
문제는 모든 명명 된 매개 변수가 필요한 것은 아니며 중첩에 따라 중괄호와 괄호가 변경된다는 것입니다.
UIView.animateWithDuration(NSTimeInterval(0.4), delay: NSTimeInterval(0.0), options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
button?.frame = CGRect(origin: CGPoint(x: scaleOriginX, y: scaleOriginY), size: CGSize(width: scaleSizeX, height: scaleSizeY))
}) { (finished) -> Void in
UIView.animateWithDuration(NSTimeInterval(0.2), delay: NSTimeInterval(0.1), options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
button?.frame = CGRect(origin: CGPoint(x: shrinkOriginX, y: shrinkOriginY), size: CGSize(width: shrinkSizeX, height: shrinkSizeY))
}, completion: { (finished) -> Void in
UIView.animateWithDuration(NSTimeInterval(0.2), delay: NSTimeInterval(0.0), options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
button?.frame = buttonFrame!
}, completion: { (finished) -> Void in
button?.userInteractionEnabled = true
})
})
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다