ios - Chat Bubble in Swift3 -
i trying draw chat bubble , looks attached picture.
using beizer path mask draw shape , set mask textview. code follows ,
let xposition = self.textview.frame.origin.x let yposition = self.textview.frame.origin.y //first direction - didnt work /*let firstpoint = cgpoint(x: xposition, y: yposition) let secondpoint = cgpoint(x: uiscreen.main.bounds.width - 5, y: firstpoint.y) let thirdpoint = cgpoint(x: secondpoint.x - 15, y: secondpoint.y + 10) let fourthpoint = cgpoint(x: thirdpoint.x, y: yposition + self.textview.frame.size.height) let fifthpoint = cgpoint(x:firstpoint.x,y:fourthpoint.y)*/ //second direction - didnt work /*let firstpoint = cgpoint(x:uiscreen.main.bounds.width - 5,y:yposition) let secondpoint = cgpoint(x:xposition,y:yposition) let thirdpoint = cgpoint(x: secondpoint.x, y: yposition + self.textview.frame.size.height) let fourthpoint = cgpoint(x: firstpoint.x - 15, y: thirdpoint.y) let fifthpoint = cgpoint(x: fourthpoint.x , y: firstpoint.y + 10)*/ let firstpoint = cgpoint(x: xposition, y: yposition) let secondpoint = cgpoint(x:firstpoint.x,y:yposition + self.textview.frame.size.height) let thirdpoint = cgpoint(x: xposition + self.textview.frame.width - 20, y: secondpoint.y) let fourthpoint = cgpoint(x: thirdpoint.x, y: yposition + 15) let fifthpoint = cgpoint(x: xposition + self.textview.frame.width , y: yposition) let maskpath = uibezierpath() maskpath.move(to: firstpoint) maskpath.addline(to: secondpoint) maskpath.addline(to: thirdpoint) maskpath.addline(to: fourthpoint) maskpath.addline(to: fifthpoint) maskpath.addline(to: firstpoint) maskpath.close() let masklayer = cashapelayer() masklayer.path = maskpath.cgpath textview.layer.mask = masklayer
i tried draw lines different directions , still rectangular shape , no chat pointer shown in picture. suggestions on achieving chat bubble ?
Comments
Post a Comment