• button添加链接的title显示效果代码


    -(void)setLinks

    {

        NSString *text = @"Privacy Policy.";

        NSMutableAttributedString * attributedText = [[NSMutableAttributedString alloc] initWithString: text];

        NSRange range = NSMakeRange(0, [attributedText length]);

        [attributedText beginEditing];

        // next make the text appear with an underline

        NSRange underLineRange = range;

        range.length -= 1;

        [attributedText addAttribute: NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSSingleUnderlineStyle] range:underLineRange];

        [attributedText addAttribute:NSFontAttributeName value:PRDefaultFontWithSize(NO, 12) range:range];

        [attributedText addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithDeviceRed:237/255.0 green:187/255.0 blue:112/255.0 alpha:1] range:underLineRange];

        [attributedText addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithDeviceRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1]range:NSMakeRange([attributedText length]-1, 1)];

        [attributedText endEditing];

        [self.linkBtn setAttributedTitle:attributedText];

        [attributedText addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithDeviceRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1] range:range];

        [self.linkBtn setAttributedAlternateTitle:attributedText];

        [self.linkBtn setToolTip:@"http://www.cisdem.com/about/privacy-policy.html"];

    }

    -(IBAction)privacyPolicyLinks:(id)sender

    {

         [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.cisdem.com/about/privacy-policy.html"]];

    }

  • 相关阅读:
    14-定时器
    13-JS中的面向对象
    12-关于DOM操作的相关案例
    11-DOM介绍
    10-关于DOM的事件操作
    09-伪数组 arguments
    08-函数
    07-常用内置对象
    06-流程控制
    05-数据类型转换
  • 原文地址:https://www.cnblogs.com/PJXWang/p/5816655.html
Copyright © 2020-2023  润新知