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

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

          <bdo id='i6rsR'></bdo><ul id='i6rsR'></ul>
      2. <tfoot id='i6rsR'></tfoot>

        自定义左 &amp;右 UISegmentedControl 按钮

        时间:2023-05-31

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

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

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

              <legend id='E0gLc'><style id='E0gLc'><dir id='E0gLc'><q id='E0gLc'></q></dir></style></legend>
                  本文介绍了自定义左 &amp;右 UISegmentedControl 按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试自定义以下分段控件,对第一个按钮使用左图像,对第二个按钮使用右图像.我将如何使用 UIAppearance 做到这一点?

                  I'm trying to customize the following segmented control, using a left image for the first button and a right image for the second button. How would I do this using UIAppearance?

                  我要更改以下segmentedControl:

                  I want to change the following segmentedControl:

                  类似于以下内容:

                  我想使用自定义图像的原因是我可以更改按钮的角.如果你看一下蓝色的分段控件,它更方正(我的图像有它自己的角).

                  The reason I want to use a custom image is so that I can change the corners of the buttons. If you look at the blue segmented control, it's more squared (my image has it's own corners).

                  我在想这样的事情但没有用:

                  I was thinking of something like this but no use:

                  UIImage *leftImage = [[UIImage imageNamed:@"leftControl.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
                  UIImage *rightImage = [[UIImage imageNamed:@"rightControl.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
                  
                  [[UISegmentedControl appearance] setBackgroundImage:leftImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault ];
                  [[UISegmentedControl appearance] setBackgroundImage:rightImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
                  

                  推荐答案

                  您需要提供以下图片:

                  • 选择了段背景(这有左右大写)
                  • 未选择段背景(这有左右大写)
                  • 中段,左选中,右未选中
                  • 中间段,左侧未选中,右侧选中
                  • 中间段,左侧 &选对了
                  • 中间段,左侧 &右未选中

                  然后用下面的代码来设置:

                  And then use the following code to set:

                  /* Unselected background */
                  UIImage *unselectedBackgroundImage = [[UIImage imageNamed:@"segment_background_unselected"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
                  [[UISegmentedControl appearance] setBackgroundImage:unselectedBackgroundImage
                                                             forState:UIControlStateNormal
                                                           barMetrics:UIBarMetricsDefault];
                  
                  /* Selected background */
                  UIImage *selectedBackgroundImage = [[UIImage imageNamed:@"segment_background_selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
                  [[UISegmentedControl appearance] setBackgroundImage:selectedBackgroundImage
                                                             forState:UIControlStateSelected
                                                           barMetrics:UIBarMetricsDefault];
                  
                  /* Image between two unselected segments */
                  UIImage *bothUnselectedImage = [[UIImage imageNamed:@"segment_middle_unselected"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 0, 15, 0)];
                  [[UISegmentedControl appearance] setDividerImage:bothUnselectedImage
                                               forLeftSegmentState:UIControlStateNormal
                                                 rightSegmentState:UIControlStateNormal
                                                        barMetrics:UIBarMetricsDefault];
                  
                  /* Image between segment selected on the left and unselected on the right */
                  UIImage *leftSelectedImage = [[UIImage imageNamed:@"segment_middle_left_selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 0, 15, 0)];
                  [[UISegmentedControl appearance] setDividerImage:leftSelectedImage
                                               forLeftSegmentState:UIControlStateSelected
                                                 rightSegmentState:UIControlStateNormal
                                                        barMetrics:UIBarMetricsDefault];
                  
                  /* Image between segment selected on the right and unselected on the left */
                  UIImage *rightSelectedImage = [[UIImage imageNamed:@"segment_middle_right_selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 0, 15, 0)];
                  [[UISegmentedControl appearance] setDividerImage:rightSelectedImage
                                               forLeftSegmentState:UIControlStateNormal
                                                 rightSegmentState:UIControlStateSelected
                                                        barMetrics:UIBarMetricsDefault];
                  

                  请注意,您必须调整可拉伸图像中的大写大小以匹配您的图像.

                  Note that you'll have to adjust the cap size in the stretchable images to match your images.

                  这篇关于自定义左 &amp;右 UISegmentedControl 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Storyboard 中编辑自定义 UIView 子类 下一篇:Xcode 4.2 - '...' 的声明将在此函数警告之外不

                  相关文章

                  最新文章

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

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

                      <tfoot id='aYHel'></tfoot>
                        <bdo id='aYHel'></bdo><ul id='aYHel'></ul>