zoukankan      html  css  js  c++  java
  • 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"]];

    }

  • 相关阅读:
    ioctlsocket()
    阻塞式socket例子学习
    accept()
    listen()
    WSAStartup
    C#动态操作DataTable(新增行、列、查询行、列等)
    C# 连接SQL Server数据库的几种方式--server+data source等方式
    ExcelHelper类
    c#使用椭圆签名算法制作软件序列号
    LINQ查询操作符之First、FirstOrDefault、Last、LastOrDefault、ElementAt、ElementAtOrDefault、Contains、Any、All、Count 等
  • 原文地址:https://www.cnblogs.com/PJXWang/p/5816655.html
Copyright © 2011-2022 走看看