2013-12-13 180 views
0

我已經編程式地在xcode中添加了按鈕,但是當我通過模擬器運行它時,它不會動畫,即它不像通常那樣閃爍?當按下按鈕時不動畫iOS

這是怎麼了,我增加了一個按鈕:

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]; 

回答

1

試試這個

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]; 
+0

三江源非常 –

+0

歡迎亞當Altinkaya – Sport

1

您可以添加此看到觸摸事件

closeButton.showsTouchWhenHighlighted = YES; 

或者你要使用按鈕式UIButtonTypeRoundedRect看到按鈕按下效果。