Post

Replies

Boosts

Views

Activity

Reply to UILabel with pattern image textColor can't be made accessible
Here is what I used which doesn't require images directly: class GradientLabel: UILabel {       var gradientColors: [CGColor] = []   var gradientLocations: [CGFloat] = []       override func drawText(in rect: CGRect) {           self.textColor = drawGradientColor(in: rect, colors: gradientColors, locations: gradientLocations)           super.drawText(in: rect)   }   private func drawGradientColor(in rect: CGRect, colors: [CGColor], locations: [CGFloat]) -> UIColor? {     let currentContext = UIGraphicsGetCurrentContext()     currentContext?.saveGState()     defer { currentContext?.restoreGState() }     let size = rect.size     UIGraphicsBeginImageContextWithOptions(size, false, 0)     guard let gradient = CGGradient(colorsSpace: CGColorSpaceCreateDeviceRGB(),                     colors: colors as CFArray,                     locations: locations) else { return nil }           let context = UIGraphicsGetCurrentContext()     context?.drawLinearGradient(gradient,                   start: CGPoint(x: 0.0, y: 0.0),                   end: CGPoint(x: size.width, y: 0.0),                   options: [])     let gradientImage = UIGraphicsGetImageFromCurrentImageContext()     UIGraphicsEndImageContext()     guard let image = gradientImage else { return nil }     return UIColor(patternImage: image)   } } After implementing you set the gradientColors and gradientLocations properties. You can change the gradient direction by setting "start:" and "end:" in context?.drawLinearGradient
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’22
Reply to Xcode 16 RC validate build bitcode error
Any solutions to this?
Replies
Boosts
Views
Activity
Sep ’24
Reply to Archive Failed On Xcode 16
Any solutions yet?
Replies
Boosts
Views
Activity
Sep ’24
Reply to Upload Symbols Failed on Xcode 16
Any solutions for this?
Replies
Boosts
Views
Activity
Sep ’24
Reply to Activating Portrait Effect in AVFoundation
Finally I figured that by restarting the phone the problem goes away! As weird as it sounds :)
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to UILabel with pattern image textColor can't be made accessible
Here is what I used which doesn't require images directly: class GradientLabel: UILabel {       var gradientColors: [CGColor] = []   var gradientLocations: [CGFloat] = []       override func drawText(in rect: CGRect) {           self.textColor = drawGradientColor(in: rect, colors: gradientColors, locations: gradientLocations)           super.drawText(in: rect)   }   private func drawGradientColor(in rect: CGRect, colors: [CGColor], locations: [CGFloat]) -> UIColor? {     let currentContext = UIGraphicsGetCurrentContext()     currentContext?.saveGState()     defer { currentContext?.restoreGState() }     let size = rect.size     UIGraphicsBeginImageContextWithOptions(size, false, 0)     guard let gradient = CGGradient(colorsSpace: CGColorSpaceCreateDeviceRGB(),                     colors: colors as CFArray,                     locations: locations) else { return nil }           let context = UIGraphicsGetCurrentContext()     context?.drawLinearGradient(gradient,                   start: CGPoint(x: 0.0, y: 0.0),                   end: CGPoint(x: size.width, y: 0.0),                   options: [])     let gradientImage = UIGraphicsGetImageFromCurrentImageContext()     UIGraphicsEndImageContext()     guard let image = gradientImage else { return nil }     return UIColor(patternImage: image)   } } After implementing you set the gradientColors and gradientLocations properties. You can change the gradient direction by setting "start:" and "end:" in context?.drawLinearGradient
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’22