それはうまくいきます!
Objective-C
[UIView transitionWithView:self.label
duration:.5f
options:UIViewAnimationOptionCurveEaseInOut |
UIViewAnimationOptionTransitionCrossDissolve
animations:^{
self.label.text = rand() % 2 ? @"111!" : @"42";
} completion:nil];
スウィフト2
UIView.transitionWithView(label, duration: 0.25, options: [.CurveEaseInOut, .TransitionCrossDissolve], animations: {
self.label.text = (arc4random() % 2 == 0) ? "111" : "222"
}, completion: nil)
スウィフト3、4、5
UIView.transition(with: label, duration: 0.25, options: [.curveEaseInOut, .transitionCrossDissolve], animations: {
self.label.text = (arc4random() % 2 == 0) ? "111" : "222"
}, completion: nil)