已过时setLineBreakMode警告
答
尝试
[buttonLeft.titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
答
可以尝试以下。它有点长,但我认为它会工作:
//我们只想添加我们的自定义标签一次;只有第一通应归零 UILabel titleLabel =(UILabel)[self viewWithTag: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已经在里面定制了titleLabel,所以你不需要创建另一个 – Vladimir 2011-03-02 13:13:44
答
对于UILabel
,相应的常量是现在NSLineBreakByWordWrapping
(而不是UILineBreakModeWordWrap
):
titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
答
只是检查出并更换这些枚举。
在iOS6的的previos是: -
从iOS 6中,它是: -
哇,这工作......非常感谢响应!.... .. :) – devsri 2011-03-02 13:20:38