Search code examples
iosobjective-cnsmutableattributedstring

Trim first character in NSMutableAttributedString


I am using NSMutableAttributedString to show attributed string in label. Is there way to trim first character of NSMutableAttributedString without change in attributes.


Solution

  • No because one of the attributes of the attributes is the range of the string they effect, and those will become invalid if the string length changes.

    The best approach would be to reconstruct the attributed string from scratch, which might be simple or difficult, depending on whether you know the attributes to add.