How can I get the file path from a UIImage?

前端 未结 3 2070
孤街浪徒
孤街浪徒 2021-02-20 08:29

Usually it\'s the other way around, you use the path to display the image. I was wondering if you can get the path if you already have the image.

3条回答
  •  梦毁少年i
    2021-02-20 08:56

    if you already have the image i.e. have added the file to your resources, you can use this to get the file path;

    NSString *string = [[NSBundle mainBundle] pathForResource:@"IMAGE_FILE_NAME" ofType:@"jpg"]; // or ofType:@"png", etc.
    

提交回复
热议问题