- (void)drawRect:(CGRect)rect { CGFloat lineWidth = 2; CGRect borderRect = CGRectMake(self.frame.size.width/2, self.frame.size.height - 20, 10....
UIView的setNeedsDisplay和setNeedsLayout方法。首先两个方法都是异步执行的。setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到UIGraphicsGetCurrentContext,就可以画画了。而setNeedsLayout会默认调用la...
分类:
移动开发 时间:
2015-07-09 13:08:40
阅读次数:
250
1.实线,(下划线/删除线)
写一个新类 UnderLineLabel :
UILabel
- (void)drawRect:(CGRect)rect {
// Drawing code
[super drawRect:rect];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGSize f...
分类:
移动开发 时间:
2015-07-07 11:08:01
阅读次数:
253
转自:http://jianyu996.blog.163.com/blog/static/112114555201305113018814/首先两个方法都是异步执行。layoutSubviews方便数据计算,drawRect方便视图重绘。layoutSubviews在以下情况下会被调用:1、init...
分类:
其他好文 时间:
2015-07-04 13:50:58
阅读次数:
114
第一步: //UITableView去掉自带系统的分割线 _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 第二步: //在自定义的UITableViewCell里重写drawRect:方法 #pragma mark - 绘制Cell分割线 - (v...
分类:
其他好文 时间:
2015-07-04 11:22:46
阅读次数:
251
可以利用 CGMutablePathRef 创建每个不同图形,然后再一起添加到CGContext中- (void)drawRect:(CGRect)rect{ CGContextRef ctx = UIGraphicsGetCurrentContext(); //一、 画线 ...
分类:
Web程序 时间:
2015-07-02 20:48:18
阅读次数:
151
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
UIBezierPath *path = [UI...
分类:
移动开发 时间:
2015-07-01 22:19:53
阅读次数:
259
#import "LCSView.h"
@implementation LCSView
////绘图
- (void)drawRect:(CGRect)rect
{
#if 0
//图形上下文对象
CGContextRef context = UIGraphicsGetCurrentContext();
...
分类:
移动开发 时间:
2015-06-30 18:21:10
阅读次数:
221
http://blog.csdn.net/volcan1987/article/details/9969455使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形步骤:1、新建UIBezierPath对象bezierPath2、新建C...
分类:
其他好文 时间:
2015-06-18 19:22:29
阅读次数:
118
关于UILabel和UIButton有的时候需要添加下划线,一般有两种方式通过默认的NSMutableAttributedString设置,第二种就是在drawRect中画一条下划线,本文就简单的选择第一种,第二种有兴趣的可以自己研究一下。UILabel设置下划线: UILabel *labe...
分类:
移动开发 时间:
2015-06-17 09:23:28
阅读次数:
156