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

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

        向 UIButton 添加子视图

        时间:2023-07-08
        <tfoot id='1mMRn'></tfoot>

        <small id='1mMRn'></small><noframes id='1mMRn'>

          <tbody id='1mMRn'></tbody>

              <legend id='1mMRn'><style id='1mMRn'><dir id='1mMRn'><q id='1mMRn'></q></dir></style></legend>
              <i id='1mMRn'><tr id='1mMRn'><dt id='1mMRn'><q id='1mMRn'><span id='1mMRn'><b id='1mMRn'><form id='1mMRn'><ins id='1mMRn'></ins><ul id='1mMRn'></ul><sub id='1mMRn'></sub></form><legend id='1mMRn'></legend><bdo id='1mMRn'><pre id='1mMRn'><center id='1mMRn'></center></pre></bdo></b><th id='1mMRn'></th></span></q></dt></tr></i><div id='1mMRn'><tfoot id='1mMRn'></tfoot><dl id='1mMRn'><fieldset id='1mMRn'></fieldset></dl></div>
                  <bdo id='1mMRn'></bdo><ul id='1mMRn'></ul>
                • 本文介绍了向 UIButton 添加子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将 customBadge 添加为 UIButton 的子视图 -

                  I'm trying to add a customBadge as a subview of a UIButton -

                  这是我目前的代码 -

                  this is my code so far -

                  //msg count initiaition
                  //CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"2"];
                  CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"2"
                                                                 withStringColor:[UIColor whiteColor]
                                                                  withInsetColor:[UIColor redColor]
                                                                  withBadgeFrame:YES
                                                             withBadgeFrameColor:[UIColor redColor]
                                                                       withScale:2.0
                                                                     withShining:YES];
                  
                      // Set Position of Badge 1
                  [customBadge1 setFrame:CGRectMake(self.view.frame.size.width/2-customBadge1.frame.size.width/2+_MsgHeadBtn.frame.size.width/2, 110, customBadge1.frame.size.width, customBadge1.frame.size.height)];
                   //add badge to view
                  [_MsgHeadBtn addSubview:customBadge1];
                  

                  我要添加子视图的按钮是 _MsgHeadBtn,它是下面屏幕截图左上方的电子邮件图标.我试图让自定义徽章略微显示在电子邮件图标的上方和右侧 - 但我最终得到了屏幕截图中的结果!

                  The button I'm trying to add the subview to is _MsgHeadBtn, which is the email icon on top LH of the screenshot below. I was trying to make the custom badge appear slighty above and to the right of the email icon - but I end up with the result in the screenshot!

                  谁能提供任何关于我哪里出错的建议!?

                  Can anyone offer any advice as to where i'm going wrong!?

                  推荐答案

                  问题出在您的 setFrame: 方法中.您正在使用 self.view.frame.size.width.

                  Issue is within your setFrame: method. You are using self.view.frame.size.width.

                  检查此代码:

                  [customBadge1 setCenter:CGPointMake(_MsgHeadBtn.frame.size.width, 0)];
                  [_MsgHeadBtn addSubview:customBadge1];
                  

                  [customBadge1 setFrame:CGRectMake(_MsgHeadBtn.frame.size.width, 0, customBadge1.frame.size.width, customBadge1.frame.size.height)];
                  [_MsgHeadBtn addSubview:customBadge1];
                  

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

                  上一篇:设置按钮类型 下一篇:更改按钮单击时的 viewController

                  相关文章

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

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

                  <legend id='NIgKO'><style id='NIgKO'><dir id='NIgKO'><q id='NIgKO'></q></dir></style></legend>
                  <tfoot id='NIgKO'></tfoot>