iphone bullet point list

后端 未结 3 1544
攒了一身酷
攒了一身酷 2020-12-03 12:39

Is there any way to make a bullet point list in iphone?

If you copy and paste a bullet point list into a UITextView in IB then it shows up. Is there anyway to do thi

3条回答
  •  借酒劲吻你
    2020-12-03 13:11

    The "bullet" character is at Unicode code point U+2022. You can use it in a string with @"\u2022" or [NSString stringWithFormat:@"%C", 0x2022].

    The "line feed" character is at Unicode code point U+000A, and is used as UIKit's newline character. You can use it in a string with @"\n".

    For example, if you had an array of strings, you could make a bulleted list with something like this:

    NSArray * items = ...;
    NSMutableString * bulletList = [NSMutableString stringWithCapacity:items.count*30];
    for (NSString * s in items)
    {
      [bulletList appendFormat:@"\u2022 %@\n", s];
    }
    textView.text = bulletList;
    

    It won't indent lines like a "proper" word processor. "Bad things" will happen if your list items include newline characters (but what did you expect?).

    (Apple doesn't guarantee that "\uXXXX" escapes work in NSString literals, but in practice they do if you use Apple's compiler.)

提交回复
热议问题