-1

I am using the following code:

bottomBorder.backgroundColor = UIColor.viewShadowGray().cgColor
        bottomBorder.frame = CGRect(x: 0, y: view.frame.size.height - 1, width: view.frame.size.width, height: 1)

In extended UIColor file:

class func viewShadowGray() -> UIColor
{
    return UIColor(red: 177.0/255.0, green: 177.0/255.0, blue: 179.0/255.0, alpha: 0.7)

}

changing the alpha value only makes the colour light, doesn't make it look blurred.

and getting :

enter image description here

I am expecting to obtain something as this:

enter image description here

How do I proceed rectifying this here?

Doj Yias Lem
  • 137
  • 8

1 Answers1

0

edited , since you tried the shadow opacity thing in your new updated question i suggest using the implemented shadow properties for UIlayer

    view.layer.masksToBounds = NO
    view.layer.shadowOffset = CGSizeMake(-15, 20)
    view.layer.shadowRadius = 5
    view.layer.shadowOpacity = 0.5
    view.layer.shadowColor = UIColor.black.cgColor

i would also recommend reading this article it would help you with that big time here

and check out this solution

extension UIView {

      // OUTPUT 1
  func dropShadow(scale: Bool = true) {
    layer.masksToBounds = false
    layer.shadowColor = UIColor.black.cgColor
    layer.shadowOpacity = 0.5
    layer.shadowOffset = CGSize(width: -1, height: 1)
    layer.shadowRadius = 1

    layer.shadowPath = UIBezierPath(rect: bounds).cgPath
    layer.shouldRasterize = true
    layer.rasterizationScale = scale ? UIScreen.main.scale : 1
  }

  // OUTPUT 2
  func dropShadow(color: UIColor, opacity: Float = 0.5, offSet: CGSize, radius: CGFloat = 1, scale: Bool = true) {
    layer.masksToBounds = false
    layer.shadowColor = color.cgColor
    layer.shadowOpacity = opacity
    layer.shadowOffset = offSet
    layer.shadowRadius = radius

    layer.shadowPath = UIBezierPath(rect: self.bounds).cgPath
    layer.shouldRasterize = true
    layer.rasterizationScale = scale ? UIScreen.main.scale : 1
  }
}

original answer here

using them like this

view.layer.dropShadow()
Mohmmad S
  • 5,001
  • 4
  • 18
  • 50
  • why not use the implemented shadow properties of the view – Mohmmad S Sep 17 '18 at 13:16
  • how do I use it? Could you explain with editing your answer. Thank you. – Doj Yias Lem Sep 17 '18 at 13:17
  • please check the new answer and tell me if it helped – Mohmmad S Sep 17 '18 at 13:24
  • its not gonna work alone there is few things to add like width and etc read the article trust me it would solve you problem and will give u a better understanding but if you want me to write you the code and just copy paste it thats another thing if you are asking me to i would do it but wouldnt really help you in the future – Mohmmad S Sep 17 '18 at 13:25
  • i added you a new lines check them @DojYiasLem – Mohmmad S Sep 17 '18 at 13:29