Skip to content
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

点击无效果,要点击拖动之后才触发事件是怎么回事? #11

Open
WeiChaoZheng opened this issue Jan 11, 2017 · 4 comments
Open

Comments

@WeiChaoZheng
Copy link

`
WS(ws); //self 的弱引用

NSMutableArray *ranges = [NSMutableArray array]; // 特殊字符的Range集合,修改文字颜色用

NSString *string = @"点击提交表明您已经阅读并同意\"条款与条件\"和\"隐私政策\"";

    
// 特殊字符的Range
    
NSRange range1 = [string rangeOfString:@"条款与条件"];
NSRange range2 = [string rangeOfString:@"隐私政策"];
    
[ranges addObject:[NSValue valueWithRange:range1]];
[ranges addObject:[NSValue valueWithRange:range2]];
    


// 转换成富文本字符串

NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:string];

[attrStr addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:11.f]} range:NSMakeRange(0, string.length)];

// 最好设置一下行高,不设的话默认是0

NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];

style.lineSpacing = 0;

[attrStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, string.length)];

// 给指定文字添加颜色

for (NSValue *rangeVal in ranges) {
    
    [attrStr addAttributes:@{NSForegroundColorAttributeName : DefaultColor} range:rangeVal.rangeValue];
    
}
//居中
NSMutableParagraphStyle *sty = [[NSMutableParagraphStyle alloc] init];
sty.alignment = NSTextAlignmentCenter;
[attrStr addAttribute:NSParagraphStyleAttributeName value:sty range:NSMakeRange(0, string.length)];

_fuWuYuTiaoKuan.attributedText = attrStr;
_fuWuYuTiaoKuan.enabledTapEffect = NO;
// 给指定文字添加点击事件,并设置代理,代理中监听点击
[_fuWuYuTiaoKuan yb_addAttributeTapActionWithStrings:@[@"条款与条件",@"隐私政策"] tapClicked:^(NSString *string, NSRange range, NSInteger index) {
 //自定义代码
}];

`

@lyb5834
Copy link
Owner

lyb5834 commented Jan 12, 2017

没问题啊?是不是你这个label本身还有别的点击事件什么的?

@WeiChaoZheng
Copy link
Author

嗯,找到问题了,在全屏幕中加个了Tap手势,应该是被拦截,现在已经解决了

@WeiChaoZheng
Copy link
Author

c55fe215-3e3c-f9bb-6ca1-dd93fa0e3927
WS(ws); [_tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(ws.view.mas_top).with.mas_equalTo(64); make.left.equalTo(ws.view.mas_left); make.right.equalTo(ws.view.mas_right); make.bottom.equalTo(ws.view.mas_bottom).with.mas_equalTo(48+30); }];
这个是新发现的问题

@lyb5834
Copy link
Owner

lyb5834 commented Jan 12, 2017

你的子视图都已经超出父视图的边界了,边界外的当然触发不了了啊

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

No branches or pull requests

2 participants