gpt4 book ai didi

iphone - 为什么一个 UIButton 有 3 种不同的图像属性?

转载 作者:行者123 更新时间:2023-12-01 18:01:55 25 4
gpt4 key购买 nike

UIButton 有 3 个不同的图像属性:

当前背景图像
当前图像
ImageView

它们各自代表什么?

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIButton_Class/UIButton/UIButton.html

最佳答案

我会说 UIButton有两组图像:

  • 通过以下方式分配的人:setImage:forState:
  • 那些通过 setBackgroundImage:forState: 分配的人

  • 它们允许您为按钮设置允许状态的前景和背景图像: UIControlStateNormal , UIControlStateHighlighted , UIControlStateDisabled , UIControlStateSelected等(它们在您链接到的文档中的“控制状态”部分中进行了描述。)
    现在, currentBackgroundImagecurrentImage允许直接访问当前图像(即与按钮当前状态对应的图像)。
    另一方面, imageView允许访问 UIImageView按钮图像下的对象,以便您可以在需要时设置其属性。例如。 (来自您链接的文档):

    Although this property is read-only, its own properties are read/write. Use these properties to configure the appearance and behavior of the button’s view. For example:

        UIButton *button                   = [UIButton buttonWithType: UIButtonTypeRoundedRect];
    button.imageView.exclusiveTouch = YES;

    关于iphone - 为什么一个 UIButton 有 3 种不同的图像属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8345215/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com