【问题标题】:Quotes in button title [duplicate]按钮标题中的引号 [重复]
【发布时间】:2013-03-25 14:10:56
【问题描述】:

如何在 UIButton 的标题中输入这样的引号 << >>。我需要带有 Helvetica-Neue 的 iOS 5。默认我有" " 引号

【问题讨论】:

    标签: ios objective-c unicode uibutton


    【解决方案1】:

    这些字符的 unicode 信息是:

    »
    RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
    Unicode: U+00BB, UTF-8: C2 BB
    
    «
    LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
    Unicode: U+00AB, UTF-8: C2 AB
    

    所以要将其中一个放入字符串中,请执行以下操作:

    NSString* rightPointing = [NSString stringWithUTF8String:"\xC2\xBB"];
    NSString* leftPointing =  [NSString stringWithUTF8String:"\xC2\xAB"];
    

    看起来有点麻烦,不过你当然可以将这些字符串与其他字符串组合起来:

    NSString* buttonLabel = [NSString stringWithFormat:@"%@%@%@", leftPointing, @"Button Title", rightPointing];
    

    【讨论】:

    • 你试过了吗?它给了rightPointing = 슻
    • 该死的。固定的。混淆了\u\x 转义。这就是你在复制后编辑代码所得到的。
    • @MartinR 这样,您的解决方案就会变得更好。赞成。
    【解决方案2】:

    Xcode 和编译器完全支持 Unicode,因此您只需输入字符(如果您的键盘上有字符):

    NSString *title = @"«title»";
    

    或者,使用 Unicode 转义序列:

    NSString *title = @"\u00ABtitle\u00BB";
    

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 1970-01-01
      • 2012-06-22
      • 2013-05-16
      • 2020-12-03
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2017-10-02
      相关资源
      最近更新 更多