美文网首页
MacOS APP 设置窗口大小不可调整

MacOS APP 设置窗口大小不可调整

作者: 本帅不良 | 来源:发表于2020-09-02 14:45 被阅读0次
        override func viewDidAppear() {
            super.viewDidAppear()
            self.view.window?.styleMask.remove(.resizable)
        }
    

    1、移除resizable类型
    2、放在viewDidAppear

    我尝试过放在viewDidLoad总,无效!
    一个比较有意思的事情是:NSWindow.StyleMask的类型是OptionSet

    public struct StyleMask : OptionSet {
    
            public init(rawValue: UInt)
    
            
            public static var borderless: NSWindow.StyleMask { get }
    
            public static var titled: NSWindow.StyleMask { get }
    
            public static var closable: NSWindow.StyleMask { get }
    
            public static var miniaturizable: NSWindow.StyleMask { get }
    
            public static var resizable: NSWindow.StyleMask { get }
    
            
            @available(OSX, introduced: 10.2, deprecated: 100000, message: "Textured window style should no longer be used")
            public static var texturedBackground: NSWindow.StyleMask { get }
    
            
            public static var unifiedTitleAndToolbar: NSWindow.StyleMask { get }
    
            
            @available(OSX 10.7, *)
            public static var fullScreen: NSWindow.StyleMask { get }
    
            
            @available(OSX 10.10, *)
            public static var fullSizeContentView: NSWindow.StyleMask { get }
    
            
            public static var utilityWindow: NSWindow.StyleMask { get }
    
            public static var docModalWindow: NSWindow.StyleMask { get }
    
            public static var nonactivatingPanel: NSWindow.StyleMask { get }
    
            @available(OSX 10.6, *)
            public static var hudWindow: NSWindow.StyleMask { get }
        }
    

    参照:

    https://stackoverflow.com/questions/29338839/non-resizable-window-swift

    相关文章

      网友评论

          本文标题:MacOS APP 设置窗口大小不可调整

          本文链接:https://www.haomeiwen.com/subject/cwcwsktx.html