study - iOS
iOS SVG file import .. path 가져오기
ODING2
2019. 4. 21. 23:38
SVG 파일을 xcode에서 쓰려고 하면
두 단계를 걸치면 된다!
(디자이너가 보통 일러로 svg를 만들어주지만, 혹시 파일이 없을 경우! png를 변환하자)
0.png -> svn 변환 (https://convertio.co/kr/png-svg/)
1. .svn파일 ->xml 로 변환 (http://a-student.github.io/SvgToVectorDrawableConverter.Web/) 여기서 변환할 수 있음~_~
2. xml -> nsstring
Xcode에 올려 보려고 시도했는데, svg 파일 자체를 한번에 업로드 해 주는 git 발견하여 ... 쓸모없게됨
여튼 필요한 상황이라면
아래와 같이 해주자...
NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"xml"];
NSData *xmlData = [NSData dataWithContentsOfFile:xmlPath];
NSString *string = [[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding];