swift - Custom Tab Bar button Not hiiding on push -
i have 5 tabs , center button custom, created uitabbarcontroller class customize center button. happening when hidesbottombarwhenpushed tab bar becomes hidden except center custom button still visible & not disabled , when tab
class tabbar: uitabbarcontroller { @iboutlet weak var centerbutton:uibutton! override func viewdidload() { super.viewdidload() let nimage = uiimage(named: "infobutton") let bimage = uiimageview(image: nimage!) bimage.frame.size = cgsize(width: 50, height: 50) let cbutton: uibutton = uibutton.buttonwithtype(uibuttontype.custom) uibutton cbutton.autoresizingmask = uiviewautoresizing.flexiblerightmargin | uiviewautoresizing.flexibleleftmargin | uiviewautoresizing.flexibletopmargin | uiviewautoresizing.flexiblebottommargin cbutton.frame = cgrectmake(0,0, 50, 50) cbutton.setbackgroundimage(nimage, forstate: uicontrolstate.normal) cbutton.setbackgroundimage(nimage, forstate: uicontrolstate.highlighted) cbutton.addtarget(self, action: "buttonpressed:", forcontrolevents: uicontrolevents.touchupinside) self.centerbutton = cbutton var heightdifference:cgfloat = bimage.frame.size.height - self.tabbar.frame.size.height if (heightdifference < 0) { cbutton.center = self.tabbar.center; } else { var center:cgpoint = self.tabbar.center; center.y = center.y - heightdifference/2.0; cbutton.center = center } self.view.addsubview(cbutton) } func buttonpressed(sender:uibutton) { self.selectedindex = 2 } }
Comments
Post a Comment