2014-01-22 5 views
0

나는 한쪽에서만 uiview를 이동하려는 응용 프로그램을 만들고 있는데 한 점 (-y 점)을 변경해야합니다. enter image description here한 지점에서 uiview 이동하는 방법

하지만 난이 원하는 :

은 현재

로 표시 뷰 내가 시도

enter image description here

을이 :

UIView *viewRed=(UIView*)[self.view viewWithTag:11]; 
    float angle = M_PI/10; //rotate 180°, or 1 π radians 
    viewRed.layer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0); 
+0

추가 달성 회전보기에서 기본보기에 놓습니다. – Optimistic

+0

@MidhunMP : 업데이트 된 질문을 확인하십시오. 제발 도와주세요. – Optimistic

+0

CAShapeLayer와 CATextLayer를 동일하게 사용하려면 CoreText와 NSAttributedString도 확인하십시오. –

답변

1

를 사용하여 원하는 모양으로 이미지 실험실 뒤에 레이어를 만들거나 원하는 모양으로 ELS 것은

편집 :

UIBezierPath *aPath = [UIBezierPath bezierPath]; 
    // Set the starting point of the shape. 
[aPath moveToPoint:CGPointMake(0.0, 300)]; 

// Draw the lines. 
[aPath addLineToPoint:CGPointMake(self.view.frame.size.width, 300.0)]; 

[aPath addLineToPoint:CGPointMake(self.view.frame.size.width, 200.0)]; 

[aPath addLineToPoint:CGPointMake(0.0, 120.0)]; 


CAShapeLayer *shapeLayer = [CAShapeLayer layer]; 
shapeLayer.path = aPath.CGPath; 
shapeLayer.fillColor = [[[UIColor redColor] colorWithAlphaComponent:0.5] CGColor]; 
[self.view.layer addSublayer:shapeLayer]; 
+0

어떻게 레이어를 그릴 수 있습니까? 나는 스토리 보드에서 uiview를 사용합니다. – Optimistic

+0

thnks하지만 내가 경의를 바꾸면 지원하지 않습니다. : – Optimistic

+0

그리고 내가보기에 설정되어 있지 않습니다. 어느 프레임을 self.view의 하단에 설정해야합니까? – Optimistic

1

사용 CAShapeLayer이

 CGMutablePathRef path = CGPathCreateMutable(); 
    CGPathMoveToPoint(path,NULL,0.0,200.0); 
    CGPathAddLineToPoint(path, NULL, 320.0f, 250.0f); 
    CGPathAddLineToPoint(path, NULL, 320.0f, 367.0f); 
    CGPathAddLineToPoint(path, NULL, 0.0f, 367.0f); 
    CGPathAddLineToPoint(path, NULL, 0.0f, 200.0f); 


    CAShapeLayer *shapeLayer = [CAShapeLayer layer]; 
    [shapeLayer setPath:path]; 
    [shapeLayer setFillColor:[[UIColor redColor] CGColor]]; 
    [shapeLayer setStrokeColor:[[UIColor blackColor] CGColor]]; 
    [shapeLayer setBounds:CGRectMake(0.0f, 0.0f, 160.0f, 480)]; 
    [shapeLayer setAnchorPoint:CGPointMake(0.0f, 0.0f)]; 
    [shapeLayer setPosition:CGPointMake(0.0f, 0.0f)]; 
    [[[self view] layer] addSublayer:shapeLayer]; 

    CGPathRelease(path); 
+0

Thnk u Frndu. :) – Optimistic

0

이 UIViwe 클래스는 모양을 그릴 만들고 baseview에 내가 labled 삭제 한

@interface ShapeView : UIView 

@end 

@implementation fractalTriangel 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
} 
    return self; 
} 

- (void)drawRect:(CGRect)rect 
{ 
CGContextRef ctx = UIGraphicsGetCurrentContext(); 

    CGContextBeginPath(ctx); 
    CGContextMoveToPoint (ctx, point1.x,point1.y); 
    CGContextAddLineToPoint(ctx, point2.x,point2.y); 
    CGContextAddLineToPoint(ctx, point3.x,point3.y); 
    CGContextAddLineToPoint(ctx, point4.x,point4.y); 
    CGContextClosePath(ctx); 

    CGContextSetRGBFillColor(ctx, 1,1, 1, 1);//set color 

    CGContextFillPath(ctx); 
} 


@end 
관련 문제