Closed baecheung closed 8 years ago
Text Attributes 1入口,仅显示Border时
NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:@"Border"]; one.yy_font = [UIFont boldSystemFontOfSize:30]; one.yy_color = [UIColor colorWithRed:1.000 green:0.029 blue:0.651 alpha:1.000]; YYTextBorder *border = [YYTextBorder borderWithLineStyle:YYTextLineStyleSingle lineWidth:1 strokeColor:[UIColor colorWithRed:1.000 green:0.029 blue:0.651 alpha:1.000]]; border.cornerRadius = 3; border.insets = UIEdgeInsetsMake(-4, -4, -4, -4); one.yy_textBackgroundBorder = border; YYLabel *label = [YYLabel new]; label.attributedText = one; label.width = self.view.width; label.height = self.view.height - (kiOS7Later ? 64 : 44); label.top = (kiOS7Later ? 64 : 0); label.textAlignment = NSTextAlignmentCenter; label.textVerticalAlignment = YYTextVerticalAlignmentCenter; label.numberOfLines = 0; label.backgroundColor = [UIColor colorWithWhite:0.933 alpha:1.000]; [self.view addSubview:label];
border 超过了视图边界,所以被裁剪掉了。这需要把 Label 视图调高一些,为 border 提供足够的空间。
@ibireme Label已经是全屏幕了,应该怎么调呢?这个就是你Demon中的例子
label.textContainerInset = UIEdgeInsetsMake(5, 5, 5, 5);
@ibireme 非常感谢!
Text Attributes 1入口,仅显示Border时