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

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

      <tfoot id='hCmfw'></tfoot>
      • <bdo id='hCmfw'></bdo><ul id='hCmfw'></ul>
      1. <small id='hCmfw'></small><noframes id='hCmfw'>

        iOS 15 中的 UIButton 图像行为发生了变化?

        时间:2023-07-09
          <bdo id='h9bpq'></bdo><ul id='h9bpq'></ul>
            <tbody id='h9bpq'></tbody>

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

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

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

                • <tfoot id='h9bpq'></tfoot>
                • 本文介绍了iOS 15 中的 UIButton 图像行为发生了变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的代码很简单;我有一个 UIButton 的出口,button,我正在代码中设置它的图像:

                  My code is very simple; I have an outlet to a UIButton, button, and I am setting its image in code:

                      let jack = UIImage(named:"jack.png")
                      self.button.setImage(jack, for:.normal)
                  

                  问题是它的行为不像我预期的那样.我希望按钮图像的大小可以缩小到按钮大小,并且我希望它是一个 template 图像(使用继承的色调着色).相反,我看到的是 original 图像,它是全尺寸的.这是 iOS 15 的变化吗?

                  The problem is that this is not behaving as I expect. I expect the button image to be sized down to the button size, and I expect it to be a template image (tinted with the inherited tint color). Instead, I'm seeing the original image and it is full-sized. Is this a change in iOS 15?

                  似乎是这样,因为如果我将项目的部署目标设置为 iOS 14 并在 iOS 14 模拟器上运行它,我确实会得到我期望的行为.

                  It seems to be, because if I set my project's deployment target to iOS 14 and run it on an iOS 14 simulator, I do get the behavior that I expect.

                  推荐答案

                  这是 iOS 15 的变化吗?

                  Is this a change in iOS 15?

                  是和不是.iOS 15 确实发生了变化,但您遇到问题的原因是 Xcode 13 发生了变化.

                  Yes and no. There is indeed a change in iOS 15, but the reason for the problem you're experiencing is a change in Xcode 13.

                  iOS 15 的变化在于有一种全新的按钮配置方式.首先为按钮提供四种新的 iOS 15 类型之一:普通、灰色、有色和填充.如果您将按钮设置为具有这些类型中的任何一种,则表示您选择了新行为.

                  The change in iOS 15 is that there's a whole new way of configuring a button. This starts with giving the button one of four new iOS 15 types: Plain, Gray, Tinted, and Filled. If you set your button to have any of those types, you are opting in to the new behavior.

                  您看到的问题是,在 Xcode 13 中,当您在情节提要中创建一个按钮时,它确实为该按钮提供了以下类型之一:Plain.所以你在不知不觉中选择了新的分配!

                  The problem you're seeing is because, in Xcode 13, when you make a button in the storyboard, it does give the button one of those types: Plain. So you have opted into the new dispensation without knowing it!

                  如果您想要旧的行为,解决方案是将样式弹出菜单(在属性检查器中)从普通更改为默认.现在你有了一个旧式按钮,它会按照你习惯的方式运行.

                  The solution, if you want the old behavior, is to change the Style pop-up menu (in the Attributes inspector) from Plain to Default. Now you have an old-style button and it will behave in the way you're accustomed to.

                  (当然,从长远来看,你会想要采用新的分配方式.我只是在解释行为的明显变化.)

                  (Of course, in the long run, you're going to want to adopt the new dispensation. I'm just explaining the apparent change in behavior.)

                  这篇关于iOS 15 中的 UIButton 图像行为发生了变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:多行 UIButton 和自动布局 下一篇:UIButton 删除所有目标动作

                  相关文章

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

                • <tfoot id='4NBd0'></tfoot>

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