开发者

Multiline text in cocoa touch button?

The foll开发者_开发技巧owing code don't show up multiline text

UIButton * viewedYou = [UIButton buttonWithType: UIButtonTypeCustom];
viewedYou.frame = CGRectMake(0.0,0.0,61,30);
[viewedYou setTitle:@"Viewed\nYou" forState:UIControlStateNormal];
[self.view addSubview:viewedYou];


do

viewedYou.titleLabel.numberOfLines = 0;
viewedYou.titleLabel.lineBreakMode = UILineBreakModeWordWrap;


Duplicate question: UIButton : Multiline text . But in your case:

    UIButton * viewedYou = [UIButton buttonWithType: UIButtonTypeCustom];
    viewedYou.frame = CGRectMake(0.0,0.0,61,30);

UILabel* viewedYouLabel = [[UILabel alloc] initWithFrame: viewedYou.bounds];
    viewedYouLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
    viewedYouLabel.textAlignment = UITextAlignmentCenter;
    viewedYouLabel.frame = CGRectMake(0.0,0.0,61,30);
    viewedYouLabel.numberOfLines =2;
    viewedYouLabel.text = @"Viewed\nYou";
    [viewedYou addSubview: viewedYouLabel];

    [self.view addSubview:viewedYou];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜