iOS每日一记之———————————————zip文件的解压与压缩 and 自定义字体的使用
2016-10-18 17:24
375 查看
一 Zip文件的解压和压缩
需要下载下载SSZipArchive 一个很厉害的工具 github上面一搜就出来了 2000多颗星足以证明其的有用性下载好之后呢
使用前:
把SSZipArchive文件添加到项目中
在target中添加libz.dylib
// 解压
NSString *zipPath = @"被解压的文件路径";
NSString *destinationPath = @"解压到的目录";
[SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath];
// 压缩
NSString *zippedPath = @"压缩文件路径";
NSArray *inputPaths = [NSArray arrayWithObjects:
[[NSBundle mainBundle] pathForResource:@"photo1" ofType:@"jpg"],
[[NSBundle mainBundle] pathForResource:@"photo2" ofType:@"jpg"]
nil nil];
[SSZipArchive createZipFileAtPath:zippedPath withFilesAtPaths:inputPaths];
基本上我们都会在沙盒中去处理文件的解压的 so
一般这样写 :
//获取Documents路径
NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString*documentsPath=[paths objectAtIndex:0];
NSLog(@"path:%@",documentsPath);
//zip文件名字
NSString *zipName = @"master.zip";
//之后字符串拼接 获取整个文件在沙盒中的路径
NSString *zipPath =[NSString stringWithFormat:@"%@/%@",documentsPath,zipName];
[SSZipArchive unzipFileAtPath:zipPath toDestination:documentsPath];
二 自定义字体
将字体加载到资源目录,并在info.plist的Fonts provided by application里面添加字体的资源路径。 使用时要用字体的Family Name,有个GlyphDesigner软件打开字体,可以看到字体的Family Name。 综上,程序里面需要判断一下部署的平台,比如我用了一个mac自带的雅痞otf字体,名字改为yapi.ttf,查得Family Name
然后这样设置就行了
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames )
{
// NSLog(@"family:'%@'",familyNames);
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames )
{
printf( "\tFont: %s \n", [fontName UTF8String] );
}
}
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 250)];
label.text = @"汉体书写信息技术标准面容(一)(二)";
label.numberOfLines =0;
UIFont *font = [UIFont fontWithName:@"FZPWJW--GB1-0" size:30];
label.font = font;
[self.view addSubview:label];
}
OK 就这样 最近一直再敢项目。。。。( ⊙ o ⊙ )啊!
相关文章推荐
- 在iOS程序中使用自定义字体
- ios中使用自定义的字体
- 在ios项目中使用自定义字体
- iOS使用自定义字体 两种方法
- iOS中使用自定义字体
- iOS中使用自定义字体
- iOS中使用自定义字体
- iOS使用自定义字体
- iOS上使用自定义ttf字体
- iOS使用自定义字体
- iOS使用自定义字体
- iOS 如何使用自定义字体
- IOS 使用自定义字体的方法 (待续)
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)
- iOS游戏开发中使用自定义字体的方法
- iOS使用自定义字体 两种方法
- java 压缩解压zip文件--使用ant支持中文
- iOS使用自定义字体
- iOS使用自定义字体
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)