• <legend id='zkFu8'><style id='zkFu8'><dir id='zkFu8'><q id='zkFu8'></q></dir></style></legend>
    • <bdo id='zkFu8'></bdo><ul id='zkFu8'></ul>
    <tfoot id='zkFu8'></tfoot>

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

      1. 无法在 iOS6 中使用启用的故事板自动布局执行自定义 UIButton

        时间:2023-07-07

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

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

                <tbody id='rh1Fg'></tbody>

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

                • <bdo id='rh1Fg'></bdo><ul id='rh1Fg'></ul>
                  <tfoot id='rh1Fg'></tfoot>
                  本文介绍了无法在 iOS6 中使用启用的故事板自动布局执行自定义 UIButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我遇到了奇怪的行为.我正在使用我在控制器中设置的自定义样式按钮:

                  I faced strange behavior. I'm using custom styled button which I setup in my controller:

                  - (void)viewDidLoad
                  {
                      [super viewDidLoad];
                  
                      [self.signOutButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                      [self.signOutButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
                  
                      CAGradientLayer *btnGradient = [CAGradientLayer layer];
                      btnGradient.frame = self.signOutButton.bounds;
                      btnGradient.colors = [NSArray arrayWithObjects:
                                            (id)[[UIColor colorWithRed:102.0f / 255.0f green:102.0f / 255.0f blue:102.0f / 255.0f alpha:1.0f] CGColor],
                                            (id)[[UIColor colorWithRed:51.0f / 255.0f green:51.0f / 255.0f blue:51.0f / 255.0f alpha:1.0f] CGColor],
                                            nil];
                  
                      [self.signOutButton.layer insertSublayer:btnGradient atIndex:0];
                  }
                  

                  它在 iOS 5 中运行良好.但如果我为 iOS 6 构建这个并启用了 Storyboard 的自动布局,那么我的样式中的渐变会消失/变得透明(但标题仍然可见).

                  It works OK in iOS 5. But if I'm building this for iOS 6 with enabled Autolayout for Storyboard then gradient in my style disappears/becomes transparent (but title is still visible).

                  如果我禁用自动布局 - 渐变又回来了.有人可以用自动布局来解释这种行为吗?

                  If I'm disabling autolayout - gradient is back. Could somebody explain such behavior with autolayout?

                  推荐答案

                  在viewDidLoad中,在autolayout下,你的views还没有框架,所以你让layer有一个CGRectZero的框架.

                  In viewDidLoad, under autolayout, your views will not yet have a frame, so you are making the layer have a frame of CGRectZero.

                  您需要将此代码或至少将设置渐变层框架的部分移动到 viewDidLayoutSubviews 或类似内容.

                  You need to move this code, or at least the part where you set the frame of the gradient layer, to viewDidLayoutSubviews or similar.

                  这篇关于无法在 iOS6 中使用启用的故事板自动布局执行自定义 UIButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何“转移"从一个 UIView 到另一个 UIView 的第一响应者? 下一篇:touchesBegin &amp;touchesMove Xcode Obj C 问题

                  相关文章

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

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

                    <tfoot id='xLu8i'></tfoot>
                    <legend id='xLu8i'><style id='xLu8i'><dir id='xLu8i'><q id='xLu8i'></q></dir></style></legend>
                      <bdo id='xLu8i'></bdo><ul id='xLu8i'></ul>