Commit 27ea4ba1 by Daniel Dahan

master: fixed UIImage context issue when creating translucent image

parent 7e8a98ad
......@@ -131,10 +131,20 @@ extension UIImage {
- Returns: A UIImage that is the color passed in.
*/
open class func image(with color: UIColor, size: CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, Screen.scale)
guard let context = UIGraphicsGetCurrentContext() else {
return nil
}
context.scaleBy(x: 1.0, y: -1.0)
context.translateBy(x: 0.0, y: -size.height)
context.setBlendMode(.multiply)
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill()
UIRectFill(rect)
context.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image?.withRenderingMode(.alwaysOriginal)
......
......@@ -287,13 +287,12 @@ open class NavigationBar: UINavigationBar {
*/
open func prepare() {
barStyle = .black
isTranslucent = false
depthPreset = .depth1
interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .square1
contentScaleFactor = Screen.scale
backButtonImage = Icon.cm.arrowBack
let image = UIImage.image(with: .clear, size: CGSize(width: 1, height: 1))
let image = UIImage.image(with: .clear, size: CGSize(width: bounds.width, height: bounds.height))
shadowImage = image
setBackgroundImage(image, for: .default)
backgroundColor = .white
......
......@@ -108,7 +108,8 @@ open class NavigationController: UINavigationController {
open override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
navigationBar.width = view.width
navigationBar.setNeedsLayout()
navigationBar.layoutIfNeeded()
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment