GCKUICastButton 类
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
实现“投屏”按钮的 UIButton 的子类。
- 开始时间
- 3.0
继承自 UIButton。
- (instancetype) initWithCoder: |
|
(NSCoder *) |
decoder |
|
- (instancetype) initWithFrame: |
|
(CGRect) |
frame |
|
- (void) setInactiveIcon: |
|
(UIImage *) |
inactiveIcon |
activeIcon: |
|
(UIImage *) |
activeIcon |
animationIcons: |
|
(NSArray< UIImage * > *) |
animationIcons |
|
|
| |
为按钮的活动、非活动和动画状态设置图标。
提供的图片应均为单色且具有透明背景。图片颜色并不重要,因为按钮的浅色(tintColor
属性)决定了图片的渲染颜色。
- (void) setAccessibilityLabel: |
|
(NSString *) |
label |
forCastState: |
|
(GCKCastState) |
state |
|
|
| |
为按钮的投屏状态设置无障碍功能标签。
建议采用此方法为按钮设置无障碍标签。由 setAccessibilityLabel 设置的标签:应用于所有投屏状态。
- (BOOL) triggersDefaultCastDialog |
|
readwritenonatomicassign |
一个标志,用于指示此按钮上的触摸事件是否会触发显示框架提供的 Cast 对话框。
默认情况下,此属性设置为 YES
。如果应用希望自行处理触控事件,则应将该属性设置为 NO
,并为触控事件注册适当的目标和操作。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003eGCKUICastButton\u003c/code\u003e is a subclass of \u003ccode\u003eUIButton\u003c/code\u003e that provides a pre-built "Cast" button for iOS applications.\u003c/p\u003e\n"],["\u003cp\u003eIt offers customization options for icons representing active, inactive, and animated states, ensuring visual alignment with the app's design.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can manage the button's accessibility labels to enhance usability for users with disabilities.\u003c/p\u003e\n"],["\u003cp\u003eWhile it defaults to triggering the Cast dialog, this behavior can be overridden to allow custom touch event handling within the application.\u003c/p\u003e\n"],["\u003cp\u003eThis class simplifies Cast integration by providing a ready-made UI element and handling the display of the standard Cast dialog.\u003c/p\u003e\n"]]],[],null,["# GCKUICastButton Class\n\n[Instance Methods](#pub-methods) \\| [Properties](#properties) \nGCKUICastButton Class Reference \n\nOverview\n--------\n\nA subclass of [**UIButton**](https://goo.gl/VK61wU) that implements a \"Cast\" button.\n\nSince\n: 3.0\n\nInherits UIButton.\n\n|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Instance Method Summary ----------------------- ||\n| (instancetype) | - [initWithCoder:](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button#a23413a39b3e6a8b12834d34c68f74445) |\n| | Constructs a new [GCKUICastButton](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button \"A subclass of UIButton that implements a \\\"Cast\\\" button. \") using the given decoder. [More...](#a23413a39b3e6a8b12834d34c68f74445) |\n| ||\n| (instancetype) | - [initWithFrame:](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button#a79e5ad64b3c53b6dbc14defda46429d3) |\n| | Constructs a new [GCKUICastButton](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button \"A subclass of UIButton that implements a \\\"Cast\\\" button. \") with the given frame. [More...](#a79e5ad64b3c53b6dbc14defda46429d3) |\n| ||\n| (void) | - [setInactiveIcon:activeIcon:animationIcons:](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button#aeb7e7925cdbcf8e553dd51bf0abcadc7) |\n| | Sets the icons for the active, inactive, and animated states of the button. [More...](#aeb7e7925cdbcf8e553dd51bf0abcadc7) |\n| ||\n| (void) | - [setAccessibilityLabel:forCastState:](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button#af6cad96ec86d102ad38a0ce3b27669d3) |\n| | Sets the accessibility label for the cast states of the button. [More...](#af6cad96ec86d102ad38a0ce3b27669d3) |\n| ||\n\n|------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| BOOL | [triggersDefaultCastDialog](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button#aa0f22a89c101e9d6c4b233e72ddf815c) |\n| | A flag that indicates whether a touch event on this button will trigger the display of the Cast dialog that is provided by the framework. [More...](#aa0f22a89c101e9d6c4b233e72ddf815c) |\n| ||\n\nMethod Detail\n-------------\n\n|---------------------------------|---|--------------|-----------|---|\n| - (instancetype) initWithCoder: | | (NSCoder \\*) | *decoder* | |\n\nConstructs a new [GCKUICastButton](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button \"A subclass of UIButton that implements a \\\"Cast\\\" button. \") using the given decoder. \n\n|---------------------------------|---|----------|---------|---|\n| - (instancetype) initWithFrame: | | (CGRect) | *frame* | |\n\nConstructs a new [GCKUICastButton](/cast/v3/reference/ios/interface_g_c_k_u_i_cast_button \"A subclass of UIButton that implements a \\\"Cast\\\" button. \") with the given frame. \n\n|---------------------------|---|------------------------------|------------------|\n| - (void) setInactiveIcon: | | (UIImage \\*) | *inactiveIcon* |\n| activeIcon: | | (UIImage \\*) | *activeIcon* |\n| animationIcons: | | (NSArray\\\u003c UIImage \\* \\\u003e \\*) | *animationIcons* |\n| | | | |\n\nSets the icons for the active, inactive, and animated states of the button.\n\nThe supplied images should all be single-color with a transparent background. The color of the images is not significant, as the button's tint color (`tintColor` property) determines the color that they are rendered in. \n\n|---------------------------------|---|--------------------------------------------------------------------------------------------|---------|\n| - (void) setAccessibilityLabel: | | (NSString \\*) | *label* |\n| forCastState: | | ([GCKCastState](/cast/v3/reference/ios/g_c_k_common_8h#af0c098ac6b7bff89f13f0bad7b88a5b5)) | *state* |\n| | | | |\n\nSets the accessibility label for the cast states of the button.\n\nThis is the recommended way to set accessibility label for the button. Label set by setAccessibilityLabel: is applied to all cast states.\n\nProperty Detail\n---------------\n\n|-------------------------------------------------------------------------------|--------------------------|\n| |------------------------------------| | - (BOOL) triggersDefaultCastDialog | | readwritenonatomicassign |\n\nA flag that indicates whether a touch event on this button will trigger the display of the Cast dialog that is provided by the framework.\n\nBy default this property is set to `YES`. If an application wishes to handle touch events itself, it should set the property to `NO` and register an appropriate target and action for the touch event."]]