美文网首页
给导航栏上的button设置背景按钮,参考代码:

给导航栏上的button设置背景按钮,参考代码:

作者: 志超mike | 来源:发表于2015-10-04 16:20 被阅读94次

    //导航栏左上角icon

    //create a new button

    let button: UIButton = UIButton(type: UIButtonType.System)

    //set background image for button

    button.setBackgroundImage(image, forState: UIControlState.Normal)

    //add function for button

    button.addTarget(self, action: "fbButtonPressed", forControlEvents: UIControlEvents.TouchUpInside)

    //set frame

    button.frame = CGRectMake(0, 0, 30, 30 )

    let barButton = UIBarButtonItem(customView: button)

    //assign button to navigationbar

    self.navigationItem.leftBarButtonItem = barButton

    相关文章

      网友评论

          本文标题:给导航栏上的button设置背景按钮,参考代码:

          本文链接:https://www.haomeiwen.com/subject/bqmgcttx.html