Ios 在按钮周围填充

Ios 在按钮周围填充,ios,cocos2d-iphone,Ios,Cocos2d Iphone,如何使用创建CCButton 标签 可拉伸背景图像 然后定义按钮周围的填充? 我需要在代码中执行此操作。 在Sprite Builder中,当CCLabelTTF是CCButton的一部分时,它有水平填充和垂直填充设置。我在代码中找不到相应的属性。首选大小属性就是答案。类型是CGSize 我就是这么做的: CCButton* buttonGo99 = [CCButton buttonWithTitle:@"99%" spriteFrame:[CCSpriteFrame frameWithImag

如何使用创建CCButton

标签 可拉伸背景图像 然后定义按钮周围的填充? 我需要在代码中执行此操作。 在Sprite Builder中,当CCLabelTTF是CCButton的一部分时,它有水平填充和垂直填充设置。我在代码中找不到相应的属性。

首选大小属性就是答案。类型是CGSize

我就是这么做的:

CCButton* buttonGo99 = [CCButton buttonWithTitle:@"99%" spriteFrame:[CCSpriteFrame frameWithImageNamed:@"ccbResources/ccbButtonNormal.png"] highlightedSpriteFrame:[CCSpriteFrame frameWithImageNamed:@"ccbResources/ccbButtonHighlighted.png"] disabledSpriteFrame:nil];
buttonGo99.preferredSize = CGSizeMake(80, 75);

你在找CCScale9Sprite吗?我认为您需要创建一个具有scale-9背景的CCButton,然后按照@Jonny的建议设置preferredSize。是的,背景图像状态使用了可拉伸图像,并且可能是必需的。