折叠所有功能的快捷方式 ⌘ ⌥ ⇧ ← 在 Xcode 10.1 中不再有效?
Shortcut to Fold all function ⌘ ⌥ ⇧ ← no longer work in Xcode 10.1?
如所分享,快捷键 ⌘ ⌥ ⇧ ← 可用于折叠所有功能。但是,当我在我的 Xcode 10.1 上试用时,它无法工作。
⌘ ⌥ ← 有效(折叠一个函数)。
在 Xcode 10.1 中是否删除了此默认快捷方式?
显然,⌘ ⌥ ⇧ ← 仅适用于函数 collapse。如果代码中没有函数,则什么也看不到。但是 ⌘ ⌥ ← 适用于 class、枚举等
例如下面的代码使用 ⌘ ⌥ ⇧ ←
看不到任何效果
extension UIColor {
open class var brightRedColor: UIColor {
return UIColor(red: 255.0/255.0, green: 59.0/255.0, blue: 48.0/255.0, alpha: 1.0)
}
open class var brightGreenColor: UIColor {
return UIColor(red: 76.0/255.0, green: 217.0/255.0, blue: 100.0/255.0, alpha: 1.0)
}
open class var brightBlueColor: UIColor {
return UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)
}
}
但是按下 ⌘ ⌥ ⇧ ←
后确实看到了下面的效果(包括 class func
)
class BugFactory {
// MARK: Properties
static let bugTints: [UIColor] = [.black, .brightBlueColor, .brightRedColor, .brightGreenColor]
static let shakeRotations = [Double.pi/16, Double.pi/8, Double.pi/8, Double.pi/24]
static let shakeDurations = [0.3, 3.0, 0.1, 0.5]
static let bugSize = CGSize(width: 128, height: 128)
enum BugType: Int {
case basic, slow, fast, smooth
}
var currentBugType = BugType.basic
// MARK: Create Bug
func createBug() -> UIImageView {
let bug = UIImageView(frame: CGRect(x: -100, y: -100, width: 128, height: 128))
bug.image = UIImage(named: "spider")
bug.tintColor = BugFactory.bugTints[currentBugType.rawValue]
// add simple "shake" key-frame animation
// for explanation, see http://www.objc.io/issue-12/animations-explained.html
let shakeAnimation = CABasicAnimation(keyPath: "transform.rotation")
shakeAnimation.toValue = 0.0
shakeAnimation.fromValue = BugFactory.shakeRotations[currentBugType.rawValue]
shakeAnimation.duration = BugFactory.shakeDurations[currentBugType.rawValue]
shakeAnimation.repeatCount = Float.infinity
shakeAnimation.autoreverses = true
shakeAnimation.isRemovedOnCompletion = false
bug.layer.add(shakeAnimation, forKey: "shake")
return bug
}
// MARK: Shared Instance
class func sharedInstance() -> BugFactory {
struct Singleton {
static var sharedInstance = BugFactory()
}
return Singleton.sharedInstance
}
}
如所分享,快捷键 ⌘ ⌥ ⇧ ← 可用于折叠所有功能。但是,当我在我的 Xcode 10.1 上试用时,它无法工作。
⌘ ⌥ ← 有效(折叠一个函数)。
在 Xcode 10.1 中是否删除了此默认快捷方式?
显然,⌘ ⌥ ⇧ ← 仅适用于函数 collapse。如果代码中没有函数,则什么也看不到。但是 ⌘ ⌥ ← 适用于 class、枚举等
例如下面的代码使用 ⌘ ⌥ ⇧ ←
看不到任何效果extension UIColor {
open class var brightRedColor: UIColor {
return UIColor(red: 255.0/255.0, green: 59.0/255.0, blue: 48.0/255.0, alpha: 1.0)
}
open class var brightGreenColor: UIColor {
return UIColor(red: 76.0/255.0, green: 217.0/255.0, blue: 100.0/255.0, alpha: 1.0)
}
open class var brightBlueColor: UIColor {
return UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)
}
}
但是按下 ⌘ ⌥ ⇧ ←
后确实看到了下面的效果(包括class func
)
class BugFactory {
// MARK: Properties
static let bugTints: [UIColor] = [.black, .brightBlueColor, .brightRedColor, .brightGreenColor]
static let shakeRotations = [Double.pi/16, Double.pi/8, Double.pi/8, Double.pi/24]
static let shakeDurations = [0.3, 3.0, 0.1, 0.5]
static let bugSize = CGSize(width: 128, height: 128)
enum BugType: Int {
case basic, slow, fast, smooth
}
var currentBugType = BugType.basic
// MARK: Create Bug
func createBug() -> UIImageView {
let bug = UIImageView(frame: CGRect(x: -100, y: -100, width: 128, height: 128))
bug.image = UIImage(named: "spider")
bug.tintColor = BugFactory.bugTints[currentBugType.rawValue]
// add simple "shake" key-frame animation
// for explanation, see http://www.objc.io/issue-12/animations-explained.html
let shakeAnimation = CABasicAnimation(keyPath: "transform.rotation")
shakeAnimation.toValue = 0.0
shakeAnimation.fromValue = BugFactory.shakeRotations[currentBugType.rawValue]
shakeAnimation.duration = BugFactory.shakeDurations[currentBugType.rawValue]
shakeAnimation.repeatCount = Float.infinity
shakeAnimation.autoreverses = true
shakeAnimation.isRemovedOnCompletion = false
bug.layer.add(shakeAnimation, forKey: "shake")
return bug
}
// MARK: Shared Instance
class func sharedInstance() -> BugFactory {
struct Singleton {
static var sharedInstance = BugFactory()
}
return Singleton.sharedInstance
}
}