注册 - 朋友们,帮我分析下这个iOS app的用户协议界面是怎么做的,说个思路就行了?
阿神
阿神 2017-04-17 15:36:32
[iOS讨论组]

用Labei可以做出这个效果,但是没有点击事件!重点是一定要有点击事件,用于跳转到用户协议内容界面。

阿神
阿神

闭关修行中......

全部回复(3)
迷茫

关键词1:NSAttributedString
关键词2:UILabel.attributedString

阿神

楼上的方法是可以的!
实现方式2:
可以WebView做注册页,web实现这种布局和相应非常简单!
实现方式3:
约束+Button,缺点是,如果高亮的文字正好被换行了,就不能正常布局。

高洛峰

今天刚好和楼主遇到同样的需求,采用的是UITextView的URL链接,设置UITextView.attributedText并设置代理delegate,响应的回调函数shouldInteractWithURL。

        _protocolTextView.delegate = self;
        _protocolTextView.editable = NO;
        _protocolTextView.scrollEnabled = NO;
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString
                                                        
                                                        alloc]initWithString:@"使用真实姓名能够让别人更快的找到和联系你,注册即表示同意《陌陌用户协议》"];
        [attributedString addAttribute:NSLinkAttributeName
                                 value:@"protocol://"
                                 range:[[attributedString string] rangeOfString:@"《陌陌用户协议》"]];
        
        _protocolTextView.attributedText = attributedString;
        _protocolTextView.linkTextAttributes = @{ NSForegroundColorAttributeName: [UIColor blueColor],
                                                  NSUnderlineColorAttributeName: [UIColor clearColor],
                                                  NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)};
                                                 
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
    if ([[URL scheme] isEqualToString:@"protocol"]) {
        
    }
    return YES;
}
                                              

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号