I'm working on outdated & unfinished project with migrating Objective-C code to Swift. Trying to recreate UIView stateTransition .h and .m files into Swift without any luck yet. If somebody has encountered something similar, any help of how the Objective-C code below would look in Swift format would be much appreciated.
//Code in UIView stateTransition header file:
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIView (stateTransition)
- (CATransition *)makeStandardStateTransition;
@end
NS_ASSUME_NONNULL_END
//Code in UIView stateTransition implementation file:
#import "UIView stateTransition.h"
NS_ASSUME_NONNULL_BEGIN
@implementation UIView (stateTransition)
- (CATransition *)makeStandardStateTransition
{
CATransition *transition = [CATransition animation];
transition.duration = 0.12;//based on testing
transition.type = kCATransitionFade;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
return transition;
}
@end
NS_ASSUME_NONNULL_END
CodePudding user response:
swift equivalent of this code would look like that:
extension UIView {
func makeStandardStateTransition() -> CATransition {
let transition = CATransition()
transition.duration = 0.12
transition.type = .fade
transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
return transition
}
}