1

For applying shadow effect on view I am using the below code.

func addShadowImage(parentview:UIView){

    parentview.layer.shadowColor = UIColor.redColor().CGColor
    parentview.layer.masksToBounds = false

    //for bottom shadow on view
    parentview.layer.shadowOffset = CGSizeMake(0,1.0)
    parentview.layer.shadowOpacity = 0.7
    parentview.layer.shadowRadius = 1.0


    //for bottom and right sides shadow on view
    parentview.layer.shadowOffset = CGSizeMake(1.0,1.0)
    parentview.layer.shadowOpacity = 1
    parentview.layer.shadowRadius = 1.0


    //for empty shadow on view
    parentview.layer.shadowOffset = CGSizeMake(0,0)
    parentview.layer.shadowOpacity = 1
    parentview.layer.shadowRadius = 0

    //for bottom and right and left sides shadow on view
    parentview.layer.shadowOffset = CGSizeMake(0,2.0)
    parentview.layer.shadowOpacity = 1
    parentview.layer.shadowRadius = 2.0

    //for four sides shadow on view
    parentview.layer.shadowOffset = CGSizeMake(0,0)
    parentview.layer.shadowOpacity = 1.0
    parentview.layer.shadowRadius = 5.0
}

Now simply call the above function with parameter type is UIView self.addShadowImage(yourViewObject)

Then it's working fine, But this shadow effected on all its subviews.

So now I want to apply a shadow effect on specific view and specific side(i.e either left or right/bottom/top).

Cœur
  • 37,241
  • 25
  • 195
  • 267
WeCan
  • 547
  • 2
  • 9
  • 23
  • Help full :- http://stackoverflow.com/questions/31107994/how-to-only-show-bottom-border-of-uitextfield-in-swift/34653649#34653649 – Mitul Marsoniya May 02 '16 at 07:27
  • @mitul thanks for fast reply. Its working fine but I need to apply this effect on view and this view is subview of CustomTableViewCell.Its not visualise even I increase the height property – WeCan May 02 '16 at 07:45
  • if you make sure clipToSubViews in cell.contentView is false this will work I guess. – Prajeet Shrestha May 02 '16 at 08:07
  • @prajeet sorry for lately reply to you. My problem is bottom shadow is not visible between cells. All subviews are visible no issues with subviews the issue in only shadow effect. – WeCan May 02 '16 at 10:28
  • your shadow is not visible cuz it's either clipped or overlapped by other views. – Prajeet Shrestha May 02 '16 at 10:29
  • @PrajeetShrestha ok I will check it out and thank you – WeCan May 04 '16 at 04:08

0 Answers0