• <bdo id='nCLSn'></bdo><ul id='nCLSn'></ul>

    <small id='nCLSn'></small><noframes id='nCLSn'>

    1. <i id='nCLSn'><tr id='nCLSn'><dt id='nCLSn'><q id='nCLSn'><span id='nCLSn'><b id='nCLSn'><form id='nCLSn'><ins id='nCLSn'></ins><ul id='nCLSn'></ul><sub id='nCLSn'></sub></form><legend id='nCLSn'></legend><bdo id='nCLSn'><pre id='nCLSn'><center id='nCLSn'></center></pre></bdo></b><th id='nCLSn'></th></span></q></dt></tr></i><div id='nCLSn'><tfoot id='nCLSn'></tfoot><dl id='nCLSn'><fieldset id='nCLSn'></fieldset></dl></div>
    2. <tfoot id='nCLSn'></tfoot><legend id='nCLSn'><style id='nCLSn'><dir id='nCLSn'><q id='nCLSn'></q></dir></style></legend>

      UIButton 底部阴影

      UIButton bottom shadow(UIButton 底部阴影)
        <tbody id='N1muB'></tbody>
        <bdo id='N1muB'></bdo><ul id='N1muB'></ul>
          • <tfoot id='N1muB'></tfoot>

          • <i id='N1muB'><tr id='N1muB'><dt id='N1muB'><q id='N1muB'><span id='N1muB'><b id='N1muB'><form id='N1muB'><ins id='N1muB'></ins><ul id='N1muB'></ul><sub id='N1muB'></sub></form><legend id='N1muB'></legend><bdo id='N1muB'><pre id='N1muB'><center id='N1muB'></center></pre></bdo></b><th id='N1muB'></th></span></q></dt></tr></i><div id='N1muB'><tfoot id='N1muB'></tfoot><dl id='N1muB'><fieldset id='N1muB'></fieldset></dl></div>

              1. <legend id='N1muB'><style id='N1muB'><dir id='N1muB'><q id='N1muB'></q></dir></style></legend>

                <small id='N1muB'></small><noframes id='N1muB'>

                本文介绍了UIButton 底部阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个与标准 iOS 键盘字母按钮非常相似的 UIButton.

                I have a UIButton which is very similar to the standard iOS keyboard alphabet button.

                我不确定如何像 iOS 那样只为底层创建阴影.

                I am not sure how to create a shadow only for the bottom layer like how iOS have done.

                我使用下面的代码,但我看到所有侧面都有阴影,而不仅仅是底部:

                I use the below code, but I see a shadow on all the side, not just the bottom:

                CALayer *buttonLayer = [[CALayer alloc] init];
                buttonLayer.shadowColor = [UIColor grayColor].CGColor;
                buttonLayer.shadowOffset = CGSizeMake(0.f,1.f);
                buttonLayer.masksToBounds = NO;
                buttonLayer.shadowOpacity = 1.f;
                

                你能告诉我如何达到同样的效果吗?提前致谢.

                Can you please tell me how to achieve the same effect. Thanks in advance.

                推荐答案

                可以混合使用cornerRadius 和shadow 属性.我在 iOS 8 上测试过.

                You can mix the cornerRadius and shadow properties. I tested it on iOS 8.

                目标-C:

                [self.globeButton setImage:[UIImage imageNamed:@"Globe"] forState:UIControlStateNormal];
                self.globeButton.backgroundColor = [UIColor colorWithRed:171 green:178 blue:186 alpha:1.0f];
                // Shadow and Radius
                self.globeButton.layer.shadowColor = [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.25f] CGColor];
                self.globeButton.layer.shadowOffset = CGSizeMake(0, 2.0f);
                self.globeButton.layer.shadowOpacity = 1.0f;
                self.globeButton.layer.shadowRadius = 0.0f;
                self.globeButton.layer.masksToBounds = NO;
                self.globeButton.layer.cornerRadius = 4.0f;
                

                斯威夫特:

                globeButton.setImage(UIImage(named: "Globe"), for: .normal)
                globeButton.backgroundColor = UIColor(red: 171/255, green: 178/255, blue: 186/255, alpha: 1.0)
                // Shadow Color and Radius
                globeButton.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.25).cgColor
                globeButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
                globeButton.layer.shadowOpacity = 1.0
                globeButton.layer.shadowRadius = 0.0
                globeButton.layer.masksToBounds = false
                globeButton.layer.cornerRadius = 4.0
                

                结果:

                这篇关于UIButton 底部阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                UIButton title text color(UIButton 标题文本颜色)
                Stretch background image for UIButton(为 UIButton 拉伸背景图像)
                Using Tint color on UIImageView(在 UIImageView 上使用 Tint 颜色)
                How can I change UIButton title color?(如何更改 UIButton 标题颜色?)
                iPhone UIButton - image position(iPhone UIButton - 图像位置)
                UIButton remove all target-actions(UIButton 删除所有目标动作)
                  • <bdo id='WEXxm'></bdo><ul id='WEXxm'></ul>

                      1. <small id='WEXxm'></small><noframes id='WEXxm'>

                            <tbody id='WEXxm'></tbody>
                          <legend id='WEXxm'><style id='WEXxm'><dir id='WEXxm'><q id='WEXxm'></q></dir></style></legend>

                          <i id='WEXxm'><tr id='WEXxm'><dt id='WEXxm'><q id='WEXxm'><span id='WEXxm'><b id='WEXxm'><form id='WEXxm'><ins id='WEXxm'></ins><ul id='WEXxm'></ul><sub id='WEXxm'></sub></form><legend id='WEXxm'></legend><bdo id='WEXxm'><pre id='WEXxm'><center id='WEXxm'></center></pre></bdo></b><th id='WEXxm'></th></span></q></dt></tr></i><div id='WEXxm'><tfoot id='WEXxm'></tfoot><dl id='WEXxm'><fieldset id='WEXxm'></fieldset></dl></div>

                          <tfoot id='WEXxm'></tfoot>