ios - 更改按钮的比例并在单击按钮时添加阴影

标签 ios swift uibutton shadow

enter image description here

我想改变按钮的比例,并在按钮点击时添加阴影效果,但是添加的阴影效果不完整,问题出在哪里,为什么最后一个按钮的阴影才完整?

enter image description here

 @objc func ButtonOnClicking(_ sender:homePageBtn){

    UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.3, initialSpringVelocity: 0.5, options: UIViewAnimationOptions.allowAnimatedContent, animations: {
        sender.layer.masksToBounds = false
        sender.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
        sender.layer.shadowColor = ColorHellp.getColor("333333").cgColor
        sender.layer.shadowOffset = CGSize(width: 0, height: 0)
        sender.layer.shadowRadius = 4
        sender.layer.shadowOpacity = 0.3

    }) { (isfinished) in
        print("finished")
    }
}

最佳答案

我可以看到,第一个按钮的阴影也是完整的,但看起来该按钮位于其他按钮的下方。

因此尝试诸如bringSubViewToFront之类的方法或更改z-index。

关于ios - 更改按钮的比例并在单击按钮时添加阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47408485/

相关文章:

ios - CallKit Framework 是否可以调用、接听和结束电话调用,或者仅用于 VOIP 调用?

iOS:ScrollView 分页太远

ios - 右图像按钮从右侧对齐 x 点

ios - 对 NSDictionary 的 NSArray 进行排序...未完全正常工作

ios - 将 int 转换为 NSTimeInterval

ios - WatchKit SF 等宽数字

ios - UITapGestureRecognizer 导致崩溃并显示不同的错误消息

ios - Closed::Creating a UIButton horizo​​ntal carousel with swipe and tap 手势

iphone - 如何查看以编程方式创建的 UIButton 的标签

ios - 如何使 iOS Storyboard 中初始化的对象成为单例