0
CKComponent (ComponentKit Facebook)에 대한 선을 그리는 방법은 무엇입니까?CKComponent (ComponentKit Facebook)에 대한 선을 그리는 방법은 무엇입니까?
drawrect 메서드가있는 UIView 기반 클래스를 사용하여 수행 할 수 있습니다.
[CKStackLayoutComponent newWithView:{ [ViewWithDrawrectMethod class],
{
{ CKComponentViewAttribute::LayerAttribute(@selector(setCornerRadius:)), @4.0 },
{ CKComponentViewAttribute::LayerAttribute(@selector(setBorderColor:)), (id)[[UIColor lightGrayColor] CGColor]},
{ CKComponentViewAttribute::LayerAttribute(@selector(setBorderWidth:)), @0.5},
{ @selector(setClipsToBounds:), @YES },
{ @selector(setBackgroundColor:), [UIColor whiteColor]},
}
}
@interface ViewWithDrawrectMethod : UIView
@end
@implementation ViewWithDrawrectMethod
-(void) drawRect: (CGRect) rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat dash[] = {2.0, 3.0};
CGContextSetLineDash(context, 0, dash, 1);
CGRect paperRect = self.bounds;
CGPoint startPoint = CGPointMake(paperRect.origin.x,50);
CGPoint endPoint = CGPointMake(paperRect.origin.x + paperRect.size.width, 50);
CGContextSetLineCap(context, kCGLineCapSquare);
CGContextSetStrokeColorWithColor(context, [UIColor grayColor].CGColor);
CGContextSetLineWidth(context, 0.5);
CGContextMoveToPoint(context, startPoint.x , startPoint.y);
CGContextAddLineToPoint(context, endPoint.x, endPoint.y);
CGContextStrokePath(context);
}
는하지만 의심하는 경우 CKStackLayoutComponent의 아이처럼 UIViev 기반 구성 요소를 사용할 수있는 권리? 어쩌면 더 좋은 방법이 있을까요? 사전에 응답
감사합니다.