AVAudioSession.sharedInstance().setCategory()
disappeared
Swift 4.2 中 iOS10以下不能用 AVAudioSession.sharedInstance() setCategory
可选方案:
- 使用OC
建议操作:
- 放弃 iOS9用户体验
do {
if #available(iOS 11.0, *) {
try audioSession.setCategory(.playback, mode: .default, policy: .longForm, options: []) } else if #available(iOS 10.0, *) { try audioSession.setCategory(.playback, mode: .default, options: []) } else { // Compiler error: 'setCategory' is unavailable in Swift try audioSession.setCategory(AVAudioSession.Category.playback) } } catch let error { print("Unable to configure audio sesson category: \(error)") }
NSUnderlineStyle(.patternSolid、.none)
disappeared
可选方案:
- 使用 CTUnderlineStyleModifiers
// 没有测试
NSUnderlineStyle.init(rawValue: Int(CTUnderlineStyleModifiers.patternSolid.rawValue))
- 使用其他默认值
下面是Rename操作
UIKit
Swift4/UIKit
UITableViewCell
Swift 4 | Swift 4.2 |
---|---|
UITableViewCellStyle | UITableViewCell.CellStyle |
UIEvent
Swift 4 | Swift 4.2 |
---|---|
UIEventSubtype | UIEvent.EventSubtype |
UITableView
Swift 4 | Swift 4.2 |
---|---|
UITableViewScrollPosition | UITableView.ScrollPosition |
UITableViewAutomaticDimension | UITableView.automaticDimension |
UITableViewCellEditingStyle | UITableViewCell.EditingStyle |
UITableViewRowAnimation | UITableView.RowAnimation |
UITableViewStyle | UITableView.Style |
UITableViewCellAccessoryType | UITableViewCell.AccessoryType |
UIControl
Swift 4 | Swift 4.2 |
---|---|
UIControlEvents | UIControl.Event |
UIWindow
Swift 4 | Swift 4.2 |
---|---|
UIWindowLevelAlert | UIWindow.Level.alert |
UIKeyboardFrameEndUserInfoKey | UIResponder.keyboardFrameEndUserInfoKey |
UIKeyboardFrameBeginUserInfoKey | UIResponder.keyboardFrameBeginUserInfoKey |
UIKeyboardAnimationDurationUserInfoKey | UIResponder.keyboardAnimationDurationUserInfoKey |
UIKeyboardAnimationCurveUserInfoKey | UIResponder.keyboardAnimationCurveUserInfoKey |
UIKeyboardIsLocalUserInfoKey | UIResponder.keyboardIsLocalUserInfoKey |
UIWindowDidBecomeVisible | UIWindow.didBecomeVisibleNotification |
UIWindowDidBecomeHidden | UIWindow.didBecomeHiddenNotification |
UIWindowDidBecomeKey | UIWindow.didBecomeKeyNotification |
UIWindowDidResignKey | UIWindow.didResignKeyNotification |
UIKeyboardWillShow | UIResponder.keyboardWillShowNotification |
UIKeyboardDidShow | UIResponder.keyboardDidShowNotification |
UIKeyboardWillHide | UIResponder.keyboardWillHideNotification |
UIKeyboardDidHide | UIResponder.keyboardDidHideNotification |
UIViewController
Swift 4 | Swift 4.2 |
---|---|
open func addChildViewController(_ childController: UIViewController) | open func addChild(_ childController: UIViewController) |
open func willMove(toParentViewController parent: UIViewController?) | open func willMove(toParent parent: UIViewController?) |
open func didMove(toParentViewController parent: UIViewController?) | open func didMove(toParent parent: UIViewController?) |
open func removeFromParentViewController() | open func removeFromParent() |
UIActivity
Swift 4 | Swift 4.2 |
---|---|
UIActivityType | UIActivity.ActivityType |
UIActivityIndicatorView
Swift 4 | Swift 4.2 |
---|---|
activityIndicator.activityIndicatorViewStyle | activityIndicator.style |
UIAlertController
Swift 4 | Swift 4.2 |
---|---|
UIAlertActionStyle | UIAlertAction.Style |
UIAlertControllerStyle | UIAlertController.Style |
UIPageViewController
Swift 4 | Swift 4.2 |
---|---|
UIPageViewControllerNavigationDirection | UIPageViewController.NavigationDirection |
UIPageViewControllerSpineLocation | UIPageViewController.SpineLocation |
UIPageViewControllerNavigationOrientation | UIPageViewController.NavigationOrientation |
UIPageViewControllerTransitionStyle | UIPageViewController.TransitionStyle |
UIPageViewControllerOptionsKey | UIPageViewController.OptionsKey |
UINavigationController
Swift 4 | Swift 4.2 |
---|---|
UINavigationControllerOperation | UINavigationController.Operation |
UIGestureRecognizer
Swift 4 | Swift 4.2 |
---|---|
UIGestureRecognizerStatePossible | UIGestureRecognizer.State.possible |
UIGestureRecognizerStateBegan | UIGestureRecognizer.State.began |
UIGestureRecognizerStateChanged | UIGestureRecognizer.State.changed |
UIGestureRecognizerStateEnded | UIGestureRecognizer.State.ended |
UIGestureRecognizerStateCancelled | UIGestureRecognizer.State.cancelled |
UIGestureRecognizerStateFailed | UIGestureRecognizer.State.failed |
UIGestureRecognizerStateRecognized | UIGestureRecognizer.State.recognized |
NSLayoutFormat
Swift 4 | Swift 4.2 |
---|---|
NSLayoutFormatOptions | NSLayoutConstraint.FormatOptions |
UIEdgeInsets
Swift 4 | Swift 4.2 |
---|---|
public func UIEdgeInsetsMake(_ top: CGFloat, _ left: CGFloat, _ bottom: CGFloat, _ right: CGFloat) -> UIEdgeInsets | UIEdgeInsets(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) |
public func UIEdgeInsetsInsetRect(_ rect: CGRect, _ insets: UIEdgeInsets) -> CGRect | public func inset(by insets: UIEdgeInsets) -> CGRect |
UIFontDescriptor
Swift 4 | Swift 4.2 |
---|---|
UIFontDescriptorSymbolicTraits | UIFontDescriptor.SymbolicTraits |
UIImage
Swift 4 | Swift 4.2 |
---|---|
UIKIT_EXTERN NSData * __nullable UIImagePNGRepresentation (UIImage * __nonnull image); |
public func pngData() -> Data? |
NSData * __nullable UIImageJPEGRepresentation (UIImage * __nonnull image, CGFloat compressionQuality); |
public func jpegData (compressionQuality: CGFloat) -> Data? |
UIApplication
Swift 4 | Swift 4.2 |
---|---|
UIApplicationDidEnterBackground | UIApplication.didEnterBackgroundNotification |
UIApplicationWillEnterForeground | UIApplication.willEnterForegroundNotification |
UIApplicationDidFinishLaunching | UIApplication.didFinishLaunchingNotification |
UIApplicationDidBecomeActive | UIApplication.didBecomeActiveNotification |
UIApplicationWillResignActive | UIApplication.willResignActiveNotification |
UIApplicationDidReceiveMemoryWarning | UIApplication.didReceiveMemoryWarningNotification |
UIApplicationWillTerminate | UIApplication.willTerminateNotification |
UIApplicationSignificantTimeChange | UIApplication.significantTimeChangeNotification |
UIApplicationWillChangeStatusBarOrientation | UIApplication.willChangeStatusBarOrientationNotification |
UIApplicationDidChangeStatusBarOrientation | UIApplication.didChangeStatusBarOrientationNotification |
UIApplicationDidChangeStatusBarFrame | UIApplication.didChangeStatusBarFrameNotification |
UIApplicationBackgroundRefreshStatusDidChange | UIApplication.backgroundRefreshStatusDidChangeNotification |
UIApplicationProtectedDataWillBecomeUnavailable | UIApplication.protectedDataWillBecomeUnavailableNotification |
UIApplicationProtectedDataDidBecomeAvailable | UIApplication.protectedDataDidBecomeAvailableNotification |
UIApplicationUserDidTakeScreenshot | UIApplication.userDidTakeScreenshotNotification |
UIApplicationOpenSettingsURLString | UIApplication.openSettingsURLString |
UIApplicationLaunchOptionsKey | UIApplication.LaunchOptionsKey |
UIInterfaceOrientationIsLandscape() | UIApplication.shared.statusBarOrientation.isLandscape |
UIView
Swift 4 | Swift 4.2 |
---|---|
func bringSubview (toFront view: UIView) |
func bringSubviewToFront (_ view: UIView) |
UIViewAnimationOptions | UIView.AnimationOptions() |
Foundation
NSAttributedString
Swift 4 | Swift 4.2 |
---|---|
NSAttributedStringKey | NSAttributedString.Key |
QuartzCore
CAShapeLayer
Swift 4 | Swift 4.2 |
---|---|
kCALineCapRound | CAShapeLayerLineCap.round |
kCALineCapButt | CAShapeLayerLineCap.butt |
kCALineCapSquare | CAShapeLayerLineCap.square |
kCALineJoinMiter | CAShapeLayerLineJoin.miter |
kCALineJoinRound | CAShapeLayerLineJoin.round |
kCALineJoinBevel | CAShapeLayerLineJoin.bevel |
kCAFillRuleNonZero | CAShapeLayerFillRule.nonZero |
kCAFillRuleEvenOdd | CAShapeLayerFillRule.evenOdd |