瀏覽代碼

add gradient func

marinofaggiana 5 年之前
父節點
當前提交
56ecbcf06e
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      iOSClient/RichWorkspace/NCRichWorkspace.swift

+ 10 - 0
iOSClient/RichWorkspace/NCRichWorkspace.swift

@@ -99,4 +99,14 @@ import SwiftRichString
         textView.isUserInteractionEnabled = false
         textView.sizeToFit()
     }
+    
+    func makeGradientLayer(`for` object : UIView, startPoint : CGPoint, endPoint : CGPoint, gradientColors : [Any]) -> CAGradientLayer {
+        let gradient: CAGradientLayer = CAGradientLayer()
+        gradient.colors = gradientColors
+        gradient.locations = [0.0 , 1.0]
+        gradient.startPoint = startPoint
+        gradient.endPoint = endPoint
+        gradient.frame = CGRect(x: 0, y: 0, width: object.frame.size.width, height: object.frame.size.height)
+        return gradient
+    }
 }