2012-07-11 16 views
14

की स्थापना मैं एक UIButtonUIButton फ़ॉन्ट

[self.fullListButton_ setTitle:[NSString stringWithFormat:@"%d", [self.newsfeedItem_.newsfeedToSubjects count] - 3] forState:UIControlStateNormal]; 

अंक में पाठ की स्थापना के लिए निम्नलिखित कोड है मैं इस के लिए फ़ॉन्ट सेट नहीं कर पा रहे है। मैं ऐसा कैसे करूं?

उत्तर

33

iOS के नवीनतम संस्करण में:

UIButton * myButton; 
myButton.titleLabel.font = [UIFont systemFontOfSize: 12]; 

या किसी अन्य फ़ॉन्ट तंत्र।

UIButton भागों के लिए यहाँ देखो:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/titleLabel

और यहाँ UIFont सामान के लिए:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIFont_Class/Reference/Reference.html

अपने कोड में:

self.fullListButton_.titleLabel.font = [UIFont systemFontOfSize: 12]; 

या

self.fullListButton_.titleLabel.font = [UIFont fontWithName:@"Arial" size:12]; 
+0

मैंने ऐसा किया और यह नहीं बदला – xonegirlz

+0

बटन कहां और कैसे बनाया गया है? – trumpetlicks

+1

@xonegirlz: सुनिश्चित करें कि आप सिस्टमबटन के लिए फ़ॉन्ट सेट करने की कोशिश नहीं कर रहे हैं। – chandu