【问题标题】:Shortcut to Fold all function ⌘ ⌥ ⇧ ← no longer work in Xcode 10.1?折叠所有功能的快捷方式 ⌘ ⌥ ⇧ ← 在 Xcode 10.1 中不再工作?
【发布时间】:2019-03-25 14:05:58
【问题描述】:

https://stackoverflow.com/a/46020397/3286489分享的快捷键⌘⌥⇧←可以折叠所有功能。但是,当我尝试使用 Xcode 10.1 时,它无法工作。

⌘ ⌥ ← 有效(折叠一个功能)。

Xcode 10.1 中是否删除了此默认快捷方式?

【问题讨论】:

    标签: xcode xcode10.1


    【解决方案1】:

    显然,⌘ ⌥ ⇧ ← 仅适用于函数折叠。如果代码中没有函数,则什么也看不到。但是 ⌘ ⌥ ← 适用于类、枚举等。

    例如下面的代码使用 ⌘ ⌥ ⇧ ←

    看不到任何效果
    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 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
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-10
      • 2015-03-01
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      • 2014-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多