Blue Highlighting / Focus Ring on Catalyst App

前端 未结 6 1654
夕颜
夕颜 2020-12-29 11:52

I\'m currently in the process of porting my iOS app to macOS using Project Catalyst.

All of my text fields, text views and table views have a blue outline when activ

6条回答
  •  太阳男子
    2020-12-29 12:22

    A slight improvement to Amerino's answer for greater flexibility and use in Storyboards:

    @IBDesignable
    class UITextViewCS: UITextView {
        @IBInspectable
        public var focusRing: UInt = 1 // 0-default, 1-None, 2-Exterior
    
        #if targetEnvironment(macCatalyst)
        @objc(_focusRingType)
        var focusRingType: UInt {
            guard [0, 1, 2].contains(focusRing) else { return 0 }
            return focusRing
        }
        #endif
    }
    

提交回复
热议问题