Giter VIP home page Giter VIP logo

huslidermenu's Introduction

HUSliderMenu

  • 简单易用的左划菜单
  • 有支持缩放和不缩放两种效果
  • 简单定制自己的左侧菜单,可设置文字和图片

如何使用HUSliderMenu

  • 手动导入:
    • 将HUSliderMenu文件夹中的Resource文件夹加入到项目中
    • 只要让根控制器继承HUSliderMenuViewController即可

参考

override func viewDidLoad() {
        super.viewDidLoad()
        self.backgroundImage = UIImage(named: "bg2.jpeg")! //设置背景图
        //self.transformWithScale = false	//不缩放,默认缩放
        //self.allowSpringAnimation = false		//不允许弹簧效果, 默认有弹簧效果
        //self.leftMenuBarItemTitle = "Menu"	//设置导航栏的菜单按钮文字,如果不设置,会使用默认的
        //self.leftMenuBarItemImage = ""	//设置导航栏的菜单按钮的图片,如果不设置,会使用默认的
        
        let rootView = HUFirstViewController()
        let secView = HUSecondViewController()
        let thirdView = HUThirdViewController()
        
        self.viewControllers = [rootView, secView, thirdView]   //设置左侧所有要显示的控制器,不要添加NavigationViewcontroller
    }

    override func numberOfItems() -> Int {	//左侧菜单数目
        return menuItems.count
    }

    override func leftMenu(menu: HULeftMenu, menuItemAtIndex index: Int) -> AnyObject {
        let item = menu.menuItemAtIndex(index) as! HUMenuItenCell
        /**
		*	这里设置菜单样式,标题,图标,选中颜色等
        */
        return item
    }

其实这里和UITableView的使用差不多
还可以在这个方法中设置自己的头视图,定制性很高

	func headerViewForLeftMenu(menu: HULeftMenu) -> UIView? {
        var view = UIView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 120))
   
        var icon = UIImageView(frame: CGRect(x: 40, y: 40, width: 60, height: 60))
        icon.image = UIImage(named: "user.jpg")
        icon.layer.cornerRadius = 30
        icon.layer.masksToBounds = true
        view.addSubview(icon)
        
        return view
    }

带缩放效果
image
不带缩放效果
image

这样写好后,就不用再担心菜单的问题了,可以安心的写自己要添加的控制器里面的内容了。 在自己的控制器的viewDidLoad中设置一下背景色, 不然看不到内容。 不太清楚的可以参考Sample文件夹中的例子

提醒

  • 本框架使用Swift开发, 兼容的系统>=iOS7.0

期望

  • 如果在使用过程中遇到BUG,希望你能联系我,谢谢(或者尝试下载最新的框架代码看看BUG修复没有)
  • 如果在使用过程中发现功能不够用,希望你能联系我,我非常想为这个框架增加更多好用的功能,谢谢
  • 如果需要OC版本,希望你能联系我,我会尽快制作OC版本,谢谢

huslidermenu's People

Contributors

hujewelz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.