2011-03-02 10 views

उत्तर

11

कोशिश

[buttonLeft.titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; 
+0

वाह कि प्रतिक्रिया के लिए काम किया ... बहुत बहुत शुक्रिया !! .... .. :) – devsri

1

निम्नलिखित कोशिश कर सकते हैं। यह थोड़ा लंबा है लेकिन मुझे लगता है कि यह काम करेगा:

// हम केवल एक बार हमारे कस्टम लेबल को जोड़ना चाहते हैं; केवल पहला पास शून्य UILabel शीर्षक लेबल = (UILabel) [स्वयं दृश्य WithTag: TITLE_LABEL_TAG] लौटाएगा;

if (!titleLabel) 
{ 
    // no custom label found (1st pass), we will be creating & adding it as subview 
    titleLabel = [[UILabel alloc] initWithFrame:titleRect]; 
    [titleLabel setTag:TITLE_LABEL_TAG]; 

    // make it multi-line 
    [titleLabel setNumberOfLines:0]; 
    [titleLabel setLineBreakMode:UILineBreakModeWordWrap]; 

    // title appearance setup; be at will to modify 
    [titleLabel setBackgroundColor:[UIColor clearColor]]; 
    [titleLabel setFont:[self font]]; 
    [titleLabel setShadowOffset:CGSizeMake(0, 1)]; 
    [titleLabel setTextAlignment:UITextAlignmentCenter]; 

    [self addSubview:titleLabel]; 
    [titleLabel release]; 
} 

// finally, put our label in original title view's state 
[titleLabel setText:title]; 
[titleLabel setTextColor:titleColor]; 
[titleLabel setShadowColor:titleShadowColor]; 

// and return empty rect so that the original title view is hidden 
return CGRectZero; 

}

+0

UIButton में पहले से ही अनुकूलन योग्य शीर्षक लेबल है, इसलिए आपको एक और बनाने की आवश्यकता नहीं है – Vladimir

10

UILabel के लिए, उपयुक्त निरंतर अब NSLineBreakByWordWrapping (UILineBreakModeWordWrap के बजाय):

titleLabel.lineBreakMode = NSLineBreakByWordWrapping; 
0

बस की जाँच और इन enums बदलें।

iOS6 के previos में था: - enter image description here

आईओएस 6 से यह है: -

enter image description here

संबंधित मुद्दे