iOS rounded UITextField with shadow

后端 未结 6 1743
猫巷女王i
猫巷女王i 2021-02-08 01:24

I would like to add a shadow effect to my UITextField currently what I\'m achieving is this:
As you can see the shadow is not rounded in the corners. My code:



        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-08 01:35

    Ok, I found the problem. Turns out that I was using rectangle border:

    The correct one should be:

    And the code is:

    mNickname.layer.masksToBounds = false
    mNickname.layer.shadowRadius = 3.0
    mNickname.layer.shadowColor = UIColor.blackColor().CGColor
    mNickname.layer.shadowOffset = CGSizeMake(1.0, 1.0)
    mNickname.layer.shadowOpacity = 1.0
    

    Result:

提交回复
热议问题