- (void)addGrid:(UIView *)view {
CGFloat widthView = view.frame.size.width;
CGFloat heightView = view.frame.size.height;
CGFloat size = 50;
void (^addLineWidthRect)(CGRect rect) = ^(CGRect rect) {
CALayer *layer = [[CALayer alloc] init];
[view.layer addSublayer:layer];
layer.frame = rect;
layer.backgroundColor = [[UIColor redColor] CGColor];
};
for (int i=0; i<widthView; i+=size) {
addLineWidthRect(CGRectMake(i, 0, 1, heightView));
}
for (int i=0; i<heightView; i+=size) {
addLineWidthRect(CGRectMake(0, i, widthView, 1));
}
}
网友评论