UIImage to base64 String Encoding

后端 未结 7 1715
囚心锁ツ
囚心锁ツ 2020-12-01 01:04

How to convert UIimage to base64 encoded string? I couldn\'t find any examples or codes with detailed regarding.

7条回答
  •  既然无缘
    2020-12-01 01:11

    There are changes in iOS 7 that allow this to be done without using any external categories to support Base64 encoding/decoding.

    You could just write it directly using:

    - (NSString *)base64String {
        return [UIImagePNGRepresentation(self) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    }
    

提交回复
热议问题