mur*_*npl 7 objective-c uibutton ios ios7
我在Xcode - Single View应用程序中创建了新项目.应用程序只有两个按钮.
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setBackgroundColor:[UIColor greenColor]];
[button1 setFrame:CGRectMake(0, self.view.frame.size.height-40-100, self.view.frame.size.width, 40)];
[button1 setTitle:NSLocalizedString(@"button 1", nil) forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[self.view addSubview:button1];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 setBackgroundColor:[UIColor greenColor]];
[button2 setFrame:CGRectMake(0, self.view.frame.size.height-40, self.view.frame.size.width, 40)];
[button2 setTitle:NSLocalizedString(@"button 2", nil) forState:UIControlStateNormal];
[button2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[button2 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[self.view addSubview:button2];
Run Code Online (Sandbox Code Playgroud)
当我在带有iOS 7的iPhone上运行此应用程序时,当我按下此按钮时,第二个按钮会突出显示突出显示状态.在iPhone上使用iOS 6秒按钮非常完美.
为什么iOS 7上的按钮有突出显示的延迟?
尝试在滚动视图子类中重载此方法:
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
// fix conflicts with scrolling and button highlighting delay:
if ([view isKindOfClass:[UIButton class]])
return YES;
else
return [super touchesShouldCancelInContentView:view];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3067 次 |
| 最近记录: |