// And now we just create a new UIImage from the drawing context CGImageRef cgimg = CGBitmapContextCreateImage(ctx); UIImage *img = [UIImage imageWithCGImage:cgimg]; CGContextRelease(ctx); CGImageRelease(cgimg); return img;
这个对文本一样有效;我们只需要把字符转化成CGPath。Core Text提供了那样的功能的函数,CTFontCreatePathForGlyph( )。为了使用它,我们需要创建一个带属性的字符串用我们想要渲染的文本,先把它们分割成行在分割成一个个字符。在把所有的字符转换成路径后,我们以子路径方式把它添加到一个单个的CGPath路径中。更多细节可以查看Ohmu写的Low-level text rendering这篇文章。结果看以来非常的炫酷:
有一点非常重要,CALayer在iOS系统中相对坐标系是以屏幕左上top-left为坐标原点的,在Mac OS X上以坐下bottom-left为坐标原点,但是可以通过CALayer的接口geometryFlipped垂直翻转坐标系,这个值默认是NO,设置成YES就可以把坐标系转换成左下bottom-left了,这里作者使用的左下bottom-left的坐标系。
@autoreleasepool { id __autoreleasing obj = [NSMutableArray array]; }
这与前面的源代码有何不同呢?
1 2 3 4 5 6
/* 编译器的模拟代码 */ id pool = objc_autoreleasePoolPush(); id obj = objc_msgSend(NSMutableArray, @selector(array)); objc_retainAutoreleasedReturnValue(obj); objc_autorelease(obj); objc_autoreleasePoolPop(pool);
availability属性声明f在OS X老虎系统中被引入,在OS X雪豹系统中被弃用,在OS X 山狮系统中被废弃。
这个信息被Clang用来决定什么时候使用f:函数式安全的,例如,假如Clang在OS X 美洲豹系统上编译,调用f()函数将成功。假如Clang在OS X雪豹系统中编译,函数调用将成功但是Clang会发出一个警告指明这个函数被弃用了。最后,假如Clang被引进编译OS X山狮系统的代码,函数调用将失败,因为f()函数已经不再可用了。
Fetching gem metadata from https://rubygems.org/........... Resolving dependencies...
Gem::RemoteFetcher::FetchError: SocketError: getaddrinfo: Name or service not known (https://rubygems.org/gems/rake-10.4.2.gem) An error occurred while installing rake (10.4.2), and Bundler cannot continue.
## Pushing generated _deploy website To git@github.com:wangruofeng/wangruofeng.github.io.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:wangruofeng/wangruofeng.github.io.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原因,是修改了远程仓库,导致本地本地版本落后于远程仓库版本。 最佳解决方案:
1 2 3 4
cd octopress/_deploy git pull origin master cd .. rake deploy