0

I am trying to implement a view similar to facebook news feed. I need to display a text like "USER_NAME posted a video on PAGE_NAME" . page name needs to be an uibutton that goes to the pageview when the user clicks on it. so the problem here is, the page name text is not breaking into next line if it's too long to fit in one line. I have tried NSLineBreakByWordWrapping but it's not helping.

EDIT : NSLineBreakByWordWrapping and setting numberOfLines to 0, just breaks the text to bottom of the PAGE_NAME button itself. but i need it to go to the bottom of username's.

Refer the image here to know how I'm supposed to implement enter image description here

Duke
  • 3
  • 7
  • Did you set number of lines to 0?. If text is dynamic you have to set number of lines to 0 – Sivajee Battina Apr 05 '17 at 12:36
  • cell.button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; cell.button.titleLabel.numberOfLines = 0; cell.button.titleLabel.textAlignment = NSTextAlignmentCenter; [button setTitle: [dataarray objectForKey:@"page_name"] forState: UIControlStateNormal]; – Duke Apr 05 '17 at 12:38
  • @Duke, add your updated code in question rather than in comments. – iCoderz Developers Apr 05 '17 at 12:40
  • Check my question again. it's updated. – Duke Apr 11 '17 at 12:18

2 Answers2

0

Try setting numberOfLines to 0.

button.titleLabel.numberOfLines = 0;
0

check this :

test.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
test.titleLabel.numberOfLines=0;

if u want to set fit the text to the button:

 test.titleLabel.adjustsFontSizeToFitWidth=YES;

u can use following properties too:

test.titleLabel.textAlignment = NSTextAlignmentLeft;
test.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;
NAVEEN KUMAR
  • 669
  • 6
  • 25