Skip to content

YYTextBorder insets属性中的top、bottom 值小于0时,边框绘制不出来~ #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yunhaiwu opened this issue May 27, 2016 · 11 comments
Labels

Comments

@yunhaiwu
Copy link

YYTextBorder insets属性中的top、bottom 值小于0时,边框绘制不出来~

代码:
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] init];
{
NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:@"文本二"];
one.yy_font = [UIFont boldSystemFontOfSize:10];
one.yy_color = [UIColor redColor];
YYTextBorder *border = [YYTextBorder new];
border.cornerRadius = 50;
border.insets = UIEdgeInsetsMake(-4, -10, -4, -10);
border.strokeWidth = 0.5;
border.strokeColor = one.yy_color;
border.lineStyle = YYTextLineStyleSingle;
one.yy_textBackgroundBorder = border;
[text appendAttributedString:one];
[text appendAttributedString:[self padding]];
}
_refLab.attributedText = text;

image

@yunhaiwu
Copy link
Author

border.insets = UIEdgeInsetsMake(0, -10, 0, -10); 没有问题~,总感觉这种bug比较微妙~,好像跟字体大小也有关系~

@ibireme
Copy link
Owner

ibireme commented May 27, 2016

调整 label 的高度,保证 UILabel (UIView) 大小能容纳下 border 的内容。

@yunhaiwu
Copy link
Author

YYLabel 的位置大小是 self.view.bounds

@yunhaiwu
Copy link
Author

所以高度一定够

@yunhaiwu
Copy link
Author

yunhaiwu commented May 27, 2016

  • (void)viewDidLoad {

    [super viewDidLoad];
    if (!_refLab) {
    YYLabel *lab = [[YYLabel alloc] initWithFrame:self.view.bounds];
    [lab setBackgroundColor:[UIColor grayColor]];
    [lab setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    _refLab = lab;
    [lab setTextAlignment:NSTextAlignmentCenter];
    lab.textVerticalAlignment = YYTextVerticalAlignmentCenter;
    lab.numberOfLines = 0;
    [self.view addSubview:lab];
    }
    }

@yunhaiwu
Copy link
Author

设置文本代码是在viewDidAppear 中写的

image

@ibireme
Copy link
Owner

ibireme commented May 27, 2016

定位到问题了,稍后修复。

@ibireme ibireme added the bug label May 27, 2016
@yunhaiwu
Copy link
Author

@ibireme 牛,是1.0.6 发么?

@ibireme
Copy link
Owner

ibireme commented May 27, 2016

Fixed。之后更新版本时,会推送到 CocoaPods。

@ibireme ibireme closed this as completed Jun 1, 2016
@evanzhou89
Copy link

CocoaPods导入YYKit 1.0.5版本 还会出现此问题

@ibireme
Copy link
Owner

ibireme commented Jun 28, 2016

@EvanZhou0319 更新版本啊。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants