ios - Need a tip with UIBezierPath. Triangle Shape like Instagram Sign Up View -
i'm trying create bezier path instagram triangle in picture below, must doing wrong. bezier path not show!
- (void)viewdidload { [super viewdidload]; // additional setup after loading view. } -(void)viewdidlayoutsubviews{ [super viewdidlayoutsubviews]; [self drawtriangle]; } - (ibaction)closebutton:(uibutton *)sender { [self dismissviewcontrolleranimated:yes completion:nil]; } - (void)drawtriangle{ uibezierpath* trianglepath = [uibezierpath bezierpath]; [trianglepath movetopoint:cgpointmake(self.signupbutton.center.x, self.signupbutton.frame.origin.y + 30)]; [trianglepath addlinetopoint:cgpointmake(self.signupbutton.center.x - 10, self.imageview.frame.size.height)]; [trianglepath addlinetopoint:cgpointmake(self.signupbutton.center.x + 10, self.imageview.frame.size.height)]; uicolor *fillcolor = [uicolor whitecolor]; [fillcolor setfill]; uicolor *strokecolor = [uicolor whitecolor]; [strokecolor setstroke]; [trianglepath fill]; [trianglepath stroke]; [trianglepath closepath]; }
xcode 8.2.1 • swift 3.0.2
func drawtriangle(size: cgfloat, x: cgfloat, y: cgfloat, up:bool) { let trianglelayer = cashapelayer() let trianglepath = uibezierpath() trianglepath.move(to: .zero) trianglepath.addline(to: cgpoint(x: -size, y: ? size : -size)) trianglepath.addline(to: cgpoint(x: size, y: ? size : -size)) trianglepath.close() trianglelayer.path = trianglepath.cgpath trianglelayer.fillcolor = uicolor.white.cgcolor trianglelayer.anchorpoint = .zero trianglelayer.position = cgpoint(x: x, y: y) trianglelayer.name = "triangle" view.layer.addsublayer(trianglelayer) } drawtriangle(size: 12, x: view.frame.midx/2, y: view.frame.midy, up: true) drawtriangle(size: 12, x: view.frame.midx, y: view.frame.midy, up: false)
Comments
Post a Comment