瀏覽代碼

综合-安全模块处理高保真按钮样式

tangchao 2 年之前
父節點
當前提交
92ea263598

二進制
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 13 - 16
PDF Office/PDF Office/Class/PDFTools/Secure/View/KMSecureLimitAlertView.swift

@@ -13,7 +13,8 @@ class KMSecureLimitAlertView: NSView {
     var titleLabel = NSTextField(labelWithString: "")
     private var despLabel = NSTextField(wrappingLabelWithString: "")
     var deleteButton = NSButton()
-    var funcButton = NSButton()
+    
+    var funcButtonVC: KMDesignButton?
     
     var itemClick: KMSecureLimitAlertViewItemClick?
     private var funcButtonSize: NSSize = NSMakeSize(163, 32)
@@ -38,7 +39,9 @@ class KMSecureLimitAlertView: NSView {
         self.addSubview(self.titleLabel)
         addSubview(despLabel)
         self.addSubview(self.deleteButton)
-        self.addSubview(self.funcButton)
+        
+        self.funcButtonVC = KMDesignButton(withType: .Text)
+        self.addSubview(self.funcButtonVC!.view)
     
         self.wantsLayer = true
         layer?.backgroundColor = NSColor(hex: "#E8F5FF").cgColor
@@ -66,22 +69,16 @@ class KMSecureLimitAlertView: NSView {
         self.deleteButton.target = self
         self.deleteButton.action = #selector(deleteButtonAction)
         
-        self.funcButton.title = NSLocalizedString("Remove Restrictions", comment: "")
-        self.funcButton.isBordered = false
-        self.funcButton.wantsLayer = true
-        self.funcButton.setTitleColor(NSColor(hex: "#273C62"))
-        self.funcButton.font = NSFont.SFProTextRegular(14)
-        self.funcButton.layer?.cornerRadius = 4
-        self.funcButton.layer?.borderWidth = 1
-        self.funcButton.layer?.borderColor = NSColor(hex: "#273C62").cgColor
-        self.funcButton.target = self
-        self.funcButton.action = #selector(funcButtonAction)
+        self.funcButtonVC?.stringValue = NSLocalizedString("Remove Restrictions", comment: "")
+        self.funcButtonVC?.target = self
+        self.funcButtonVC?.action = #selector(funcButtonAction)
+        self.funcButtonVC?.button(type: .Ghost, size: .m)
         
-        let size = self.funcButton.title.boundingRect(with: NSMakeSize(1000, self.funcButtonSize.height), options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [.foregroundColor : NSColor.buttonTitleColor(), .font : NSFont.SFProTextRegular(14)]).size
-        if (size.width < 40) {
+        let size = self.funcButtonVC?.stringValue.boundingRect(with: NSMakeSize(1000, self.funcButtonSize.height), options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [.foregroundColor : NSColor.buttonTitleColor(), .font : NSFont.SFProTextRegular(14)]).size
+        if (size == nil || size!.width < 40) {
             self.funcButtonSize.width = 70
         } else {
-            self.funcButtonSize.width = size.width + 34
+            self.funcButtonSize.width = size!.width + 34
         }
     }
     
@@ -101,7 +98,7 @@ class KMSecureLimitAlertView: NSView {
         self.deleteButton.frame = NSMakeRect(width-34, 10, 24, 24)
         
         let funcButtonSize = self.funcButtonSize
-        self.funcButton.frame = NSMakeRect(width-funcButtonSize.width-leftMargin, height-funcButtonSize.height-16, funcButtonSize.width, funcButtonSize.height)
+        self.funcButtonVC?.view.frame = NSMakeRect(width-funcButtonSize.width-leftMargin, height-funcButtonSize.height-16, funcButtonSize.width, funcButtonSize.height)
     }
     
     @objc private func deleteButtonAction() {