[英]Padding around CCButton
How do we create a CCButton with 我们如何使用创建CCButton
and then define the padding around the button? 然后定义按钮周围的填充? I need to do this in code.
我需要在代码中执行此操作。 In Sprite Builder, there is "Horizontal padding" and "Vertical padding" settings for CCLabelTTF when it is a part of a CCButton.
在Sprite Builder中,CCLabelTTF是CCButton的一部分时,具有“水平填充”和“垂直填充”设置。 I can't find the corresponding properties in code.
我在代码中找不到相应的属性。
The preferredSize
property is the answer. preferredSize
属性就是答案。 Type is CGSize
. 类型是
CGSize
。
So this is what I do: 所以这就是我要做的:
CCButton* buttonGo99 = [CCButton buttonWithTitle:@"99%" spriteFrame:[CCSpriteFrame frameWithImageNamed:@"ccbResources/ccbButtonNormal.png"] highlightedSpriteFrame:[CCSpriteFrame frameWithImageNamed:@"ccbResources/ccbButtonHighlighted.png"] disabledSpriteFrame:nil];
buttonGo99.preferredSize = CGSizeMake(80, 75);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.