我已经在xcode中以编程方式添加了按钮,但是当我通过模拟器运行该按钮时,它没有动画,即它没有像通常那样闪烁吗?
这就是我添加按钮的方式:
closeButton = [[UIButton alloc] init];
closeButton.frame = CGRectMake(505, 5, 20, 20);
[closeButton setImage:imgBtn forState:UIControlStateNormal];
[closeButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[closeButton addTarget:self action:@selector(closeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:closeButton];
最佳答案
尝试这个
closeButton = [[UIButton alloc] init];
closeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]
closeButton.frame = CGRectMake(505, 5, 20, 20);
[closeButton setImage:imgBtn forState:UIControlStateNormal];
[closeButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[closeButton addTarget:self action:@selector(closeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:closeButton];
关于ios - 按下iOS时按钮没有动画,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20573031/