ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.86k stars 1.7k forks source link

YYTextBorder显示不完整 #308

Closed baecheung closed 8 years ago

baecheung commented 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];
1
ibireme commented 8 years ago

border 超过了视图边界,所以被裁剪掉了。这需要把 Label 视图调高一些,为 border 提供足够的空间。

baecheung commented 8 years ago

@ibireme Label已经是全屏幕了,应该怎么调呢?这个就是你Demon中的例子

ibireme commented 8 years ago

label.textContainerInset = UIEdgeInsetsMake(5, 5, 5, 5);

baecheung commented 8 years ago

@ibireme 非常感谢!