<tfoot id='4tIIN'></tfoot>

      <bdo id='4tIIN'></bdo><ul id='4tIIN'></ul>

    <small id='4tIIN'></small><noframes id='4tIIN'>

    1. <legend id='4tIIN'><style id='4tIIN'><dir id='4tIIN'><q id='4tIIN'></q></dir></style></legend>
    2. <i id='4tIIN'><tr id='4tIIN'><dt id='4tIIN'><q id='4tIIN'><span id='4tIIN'><b id='4tIIN'><form id='4tIIN'><ins id='4tIIN'></ins><ul id='4tIIN'></ul><sub id='4tIIN'></sub></form><legend id='4tIIN'></legend><bdo id='4tIIN'><pre id='4tIIN'><center id='4tIIN'></center></pre></bdo></b><th id='4tIIN'></th></span></q></dt></tr></i><div id='4tIIN'><tfoot id='4tIIN'></tfoot><dl id='4tIIN'><fieldset id='4tIIN'></fieldset></dl></div>
    3. 如何向 UIButton 添加阴影?

      时间:2023-07-09

    4. <small id='6IxsD'></small><noframes id='6IxsD'>

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

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

                问题描述

                我想为 UIButton 添加阴影.我尝试使用 self.layer.shadow* 属性.这些属性在 UIView 中有效,但在 UIButton 中的行为不同.如果我能得到任何指示来绘制阴影,我将不胜感激.谢谢!

                I would like to add a drop shadow to a UIButton. I tried to use self.layer.shadow* properties. Those properties work in UIView, but they behave differently in UIButton. I would really appreciate it if I could get any pointers to draw the drop shadow. Thank you!

                self.layer.cornerRadius = 8.0f;
                self.layer.masksToBounds = YES;
                self.layer.borderWidth = 1.0f;
                
                self.layer.shadowColor = [UIColor greenColor].CGColor;
                self.layer.shadowOpacity = 0.8;
                self.layer.shadowRadius = 12;
                self.layer.shadowOffset = CGSizeMake(12.0f, 12.0f);
                

                推荐答案

                问题中只有一个小错误导致阴影不显示:masksToBounds:YES 也屏蔽了阴影!这是正确的代码:

                There is only one tiny mistake in the question that causes the shadow to not be displayed: masksToBounds:YES also masks the shadow! Here's the correct code:

                self.layer.cornerRadius = 8.0f;
                self.layer.masksToBounds = NO;
                self.layer.borderWidth = 1.0f;
                
                self.layer.shadowColor = [UIColor greenColor].CGColor;
                self.layer.shadowOpacity = 0.8;
                self.layer.shadowRadius = 12;
                self.layer.shadowOffset = CGSizeMake(12.0f, 12.0f);
                

                不幸的是,这意味着我们不能在没有技巧的情况下同时屏蔽内容和阴影.

                Unfortunately, this means we cannot mask the content and have a shadow at the same time without tricks.

                记得#import <QuartzCore/QuartzCore.h>.

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

                上一篇:如何缩放 UIButton 的 imageView? 下一篇:可以同时具有图像和文本的 UIButton 吗?

                相关文章

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

                  <legend id='HMWMc'><style id='HMWMc'><dir id='HMWMc'><q id='HMWMc'></q></dir></style></legend>

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

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