mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Glass updates
This commit is contained in:
parent
1425fd8973
commit
0f5a019f04
23 changed files with 1000 additions and 592 deletions
|
|
@ -396,7 +396,7 @@ public enum GradientImageDirection {
|
|||
case mirroredDiagonal
|
||||
}
|
||||
|
||||
public func generateGradientImage(size: CGSize, scale: CGFloat = 0.0, colors: [UIColor], locations: [CGFloat], direction: GradientImageDirection = .vertical) -> UIImage? {
|
||||
public func generateGradientImage(size: CGSize, scale: CGFloat = 0.0, colors: [UIColor], locations: [CGFloat], direction: GradientImageDirection = .vertical, isInverted: Bool = false) -> UIImage? {
|
||||
guard colors.count == locations.count else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -408,7 +408,11 @@ public func generateGradientImage(size: CGSize, scale: CGFloat = 0.0, colors: [U
|
|||
var locations = locations
|
||||
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
|
||||
|
||||
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: direction == .horizontal ? CGPoint(x: size.width, y: 0.0) : CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
|
||||
if isInverted {
|
||||
context.drawLinearGradient(gradient, start: direction == .horizontal ? CGPoint(x: size.width, y: 0.0) : CGPoint(x: 0.0, y: size.height), end: CGPoint(x: 0.0, y: 0.0), options: CGGradientDrawingOptions())
|
||||
} else {
|
||||
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: direction == .horizontal ? CGPoint(x: size.width, y: 0.0) : CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
|
||||
}
|
||||
}
|
||||
|
||||
let image = UIGraphicsGetImageFromCurrentImageContext()!
|
||||
|
|
|
|||
|
|
@ -116,3 +116,9 @@ open class SimpleTransformLayer: CATransformLayer {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
public final class SimpleLayerDelegate: NSObject, CALayerDelegate {
|
||||
public func action(for layer: CALayer, forKey event: String) -> CAAction? {
|
||||
return nullAction
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -881,6 +881,10 @@ public extension CALayer {
|
|||
return makeBlurFilter()
|
||||
}
|
||||
|
||||
static func variableBlur() -> NSObject? {
|
||||
return makeVariableBlurFilter()
|
||||
}
|
||||
|
||||
static func luminanceToAlpha() -> NSObject? {
|
||||
return makeLuminanceToAlphaFilter()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue