• <bdo id='22ggW'></bdo><ul id='22ggW'></ul>
    <tfoot id='22ggW'></tfoot>
    1. <legend id='22ggW'><style id='22ggW'><dir id='22ggW'><q id='22ggW'></q></dir></style></legend>

        <small id='22ggW'></small><noframes id='22ggW'>

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

        如何在一个圆圈内对齐 UIButtons?

        时间:2023-07-08

          <small id='8a1MG'></small><noframes id='8a1MG'>

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

              <bdo id='8a1MG'></bdo><ul id='8a1MG'></ul>
                <tbody id='8a1MG'></tbody>
            • <legend id='8a1MG'><style id='8a1MG'><dir id='8a1MG'><q id='8a1MG'></q></dir></style></legend>

                1. 本文介绍了如何在一个圆圈内对齐 UIButtons?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  例如,我有 20 个按钮.如何以循环格式添加此按钮的 UIView 的子视图?

                  Say for example I have 20 buttons. How can I add a subView of the UIView of this button in a circular format?

                  推荐答案

                  这会将按钮放置在给定中心的给定半径的圆周围.它还将使用 UIView 的 transform 属性旋转每个按钮.

                  This will place the buttons around a circle of a given radius at a given center. It will also rotate each button using the transform property of UIView.

                  希望对您有所帮助.:)

                  Hope it helps. :)

                  - (void)viewDidLoad
                  {
                      [super viewDidLoad];
                  
                      NSArray *buttons = /* you buttons here */
                      float curAngle = 0;
                      float incAngle = ( 360.0/(buttons.count) )*PI/180.0;
                      CGPoint circleCenter = CGPointMake(160, 200); /* given center */
                      float circleRadius = 100; /* given radius */
                      for (UIButton *button in buttons)
                      {
                          CGPoint buttonCenter;
                          buttonCenter.x = circleCenter.x + cos(curAngle)*circleRadius;
                          buttonCenter.y = circleCenter.y + sin(curAngle)*circleRadius;
                          button.transform = CGAffineTransformRotate(button.transform, curAngle);
                          button.center = buttonCenter;
                          [self.view addSubview:button];
                  
                          curAngle += incAngle;
                      }
                  }
                  

                  结果:

                  这篇关于如何在一个圆圈内对齐 UIButtons?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIButton 标题左对齐问题 (iOS/Swift) 下一篇:子类化 UIButton 但无法访问我的属性

                  相关文章

                    <bdo id='HzaBd'></bdo><ul id='HzaBd'></ul>

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

                  2. <tfoot id='HzaBd'></tfoot>
                    1. <small id='HzaBd'></small><noframes id='HzaBd'>