gpt4 book ai didi

iphone - "Blue box"显示在 iOS 应用程序中的自定义 UIButton 旁边

转载 作者:行者123 更新时间:2023-11-29 05:58:35 26 4
gpt4 key购买 nike

我正在开发一个 iPhone 应用程序,用作打开和关闭灯泡的 Remote ,并且我使用 UIButtons 来执行此操作:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];

[button setBackgroundImage:bulb_on forState:UIControlStateSelected];
[button setBackgroundImage:bulb_off forState:UIControlStateNormal];

button.frame = CGRectMake(SPACING_LEFT + (BUTTON_SPACING * buttonNum) % (NUMBER_OF_HORIZONTAL_BUTTONS * BUTTON_SPACING), SPACING_TOP + y_padding, BUTTON_SIZE_X, BUTTON_SIZE_Y);

[self.scrollView addSubview:button];

一切正常,除了一些但仍然令人烦恼的细节:

buttons

如您所见,所选按钮的左上角有某种蓝色“框”或阴影。正常状态下的按钮没有这个东西。这可能来自什么以及如何删除它?

最佳答案

我认为这是因为您创建了 UIButtonTypeRoundedRect 而不是 buttonWithType:UIButtonTypeCustom

这样做:

UIButton *button = [[UIButton alloc]initWithFrame: CGRectMake(SPACING_LEFT + (BUTTON_SPACING * buttonNum) % (NUMBER_OF_HORIZONTAL_BUTTONS * BUTTON_SPACING), SPACING_TOP + y_padding, BUTTON_SIZE_X, BUTTON_SIZE_Y)];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];

[button setBackgroundImage:bulb_on forState:UIControlStateSelected];
[button setBackgroundImage:bulb_off forState:UIControlStateNormal];

[self.scrollView addSubview:button];

关于iphone - "Blue box"显示在 iOS 应用程序中的自定义 UIButton 旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54885964/

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