08 2013 档案
UIButton 上的标题添加下划线效果
摘要:subclass UIButton类 重载drawrect方法:- (void)drawRect:(CGRect)rect { // Get the Render Context CGContextRef ctx = UIGraphicsGetCurrentContext(); // Measure the font size, so the line fits the text. // Could be that "titleLabel" is something else in other classes like U... 阅读全文
posted @ 2013-08-29 20:24 kelisi_king 阅读(869) 评论(0) 推荐(0)
方法混合(Method Swizzling):动态替换已有类的方法
摘要:动态替换类的方法在不能改变原有代码的情况下,提供了一种解决方法。貌似这种方法不太常用,不过记下来以备后患~。 功能:用这种方法可以给你的程序提供一些一般方法不能实现的功能。 例子:UIWebView的delegate接口提供了一个shouldStartLoadWithRequest()方法,可以通过NSURLRequest这个对象得到所要装载网页 的详情(head头信息等),但你不能修改这个对象(添加或修改你需要的HTTP请求头信息,比如:“User-Agent”字段),如果HTTP请求的对端,(比如硬件设备)需要各种特殊的头信息,将束手无策。但如果使用方法混合(Method Swizzli. 阅读全文
posted @ 2013-08-05 18:39 kelisi_king 阅读(932) 评论(0) 推荐(0)