首页 > 代码库 > 【代码笔记】iOS-DropDownDemo-下拉按钮效果
【代码笔记】iOS-DropDownDemo-下拉按钮效果
一,效果图。
二,工程图。
三,代码。
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];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
好文要顶 关注我 收藏该文
【代码笔记】iOS-DropDownDemo-下拉按钮效果
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。