【代码笔记】iOS-下拉菜单
2016-06-27 09:08
609 查看
一,效果图。
二,工程图。
三,代码。
RootViewController.h
RootViewController.m
二,工程图。
三,代码。
RootViewController.h
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
RootViewController.m
#import "RootViewController.h" #import "NIDropDown.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.title=@"DropDown"; UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame=CGRectMake(10, 100, 150,30); button.backgroundColor=[UIColor redColor]; [button addTarget:self action:@selector(doClickAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; } -(void)doClickAction:(UIButton *)btn { NSArray *dataArray=[NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5", nil]; NIDropDown *dropDown=[[NIDropDown alloc]init]; [dropDown showDropDown:btn andHeight:[dataArray count]*36 andData:dataArray]; [self.view addSubview:dropDown]; }
相关文章推荐
- iOS 使用Charts框架 折线,柱状,K线,饼状,雷达全攻略
- 『零行代码』解决键盘遮挡问题(iOS)
- iOS 多媒体编程(一)——音频(AudioServices、AVAudioPlayer)
- iOS-生成Bundle包-引入bundle-使用bundle
- 【转】iOS自动布局进阶用法
- 美团App iOS开发与FRP
- IOS疯狂基础之GIF图片的显示
- iOS绘制图片与文字
- iOS定时器雪花效果
- iOS图片水印实现
- iOS裁切图片(圆头像的实现)
- iOS 认知
- Xamarin iOS项目找不到模拟器
- iOS中常用的毛玻璃处理
- iOS-获取webview的 url 和 title 和 html
- iOS开发——frame和bounds详解
- iOS用SAX方式解析XML
- IOS开发之----#import、#include和@class的区别
- 最新版 CocoaPods 的安装流程
- iOS block 源码详解2