2012-05-11 35 views
0

我在我的設置頁面中有兩個UIButton,一個按鈕用於增加文本的字體大小,另一個用於減小文本的字體大小。但所有我需要的是當用戶點擊UIButton增加字體大小,它需要切割18pt,然後用戶再次點擊或再次在同一個按鈕,它需要設置字體大小爲24pt,然後再次錄音字體大小爲32pt的水泥會產生相同的按鈕。我需要限制或者輕點計數。反之亦然減小字體大小按鈕相同的效果。如何獲取UIButton中的抽頭數?

-(IBAction)_clickfontsizeincrease:(id)sender 
{ 
     self.multiPageView.font = [UIFont systemFontOfSize:30.0f]; 
} 

-(IBAction)_clickfontsizedecrease:(id)sender 
{ 
     self.multiPageView.font = [UIFont systemFontOfSize:10.0f]; 
} 

如何做到這一點?提前致謝。

回答

5
static int tapCount = 0; 
- (IBAction) buttonTapped :(id)sender { 
    tapCount++; 

    // Based upon tapCount condition you can do whatever you want. 

} 
+0

你可以解釋一下嗎? – stackiphone

+1

@stackiphone - 解釋是什麼意思? – rishi

3
float current_font_size; 

-(id) init 
{ 
    current_font_size = 10f; 
} 

-(IBAction)_clickfontsizeincrease:(id)sender 
{ 
     current_font_size += 8; 
     self.multiPageView.font = [UIFont systemFontOfSize:current_font_size]; 

} 
-(IBAction)_clickfontsizedecrease:(id)sender 
{ 
     current_font_size -= 8; 
     self.multiPageView.font = [UIFont systemFontOfSize:current_font_size]; 
} 
+0

但如何獲得水龍頭計數....這是我di,但需要通過點擊按鈕 – stackiphone

+0

獲得增加使用另一個int並計算水龍頭 – jimpic

0

必須管理某處類按鈕的狀態,例如在聲明頭文件int counterOfFontIncrease一個變量,然後增加每次這個變量的按鈕,點擊在像條件放。

if (counterOfFontIncrease == 3) 
     { 

     counterOfFontIncrease = 1; 
     } 

這樣做也可以減少字體按鈕。