IOS代碼筆記之下拉菜單效果
本文實(shí)例為大家分享了ios下拉菜單的具體代碼,供大家參考,具體內(nèi)容如下
一、效果圖


二、工程圖

三、代碼
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];
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
詳解iOS中多倒計(jì)時(shí)場(chǎng)景的解決方案
在我們開(kāi)發(fā)APP的過(guò)程中,或多或少都遇到過(guò)需要使用倒計(jì)時(shí)的場(chǎng)景,這篇文章主要介紹了詳解iOS中多倒計(jì)時(shí)場(chǎng)景的解決方案,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11
iOS開(kāi)發(fā)之TableView實(shí)現(xiàn)完整的分割線詳解
在iOS開(kāi)發(fā)中, tableView是我們最常用的UI控件之一。所以這篇文章主要給大家詳細(xì)介紹了關(guān)于iOS中的TableView分割線,有需要的朋友們可以參考借鑒,下面來(lái)一起看看吧。2016-12-12
iOS中sqlite數(shù)據(jù)庫(kù)的原生用法
這篇文章主要為大家詳細(xì)介紹了iOS中sqlite數(shù)據(jù)庫(kù)的原生用法,sqlite數(shù)據(jù)庫(kù)相信各位早已耳聞,非常輕巧的一個(gè)數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)僅一個(gè)文件,即建即用,感興趣的小伙伴們可以參考一下32016-05-05
iOS開(kāi)發(fā)教程之登錄與訪客的邏輯實(shí)現(xiàn)
這篇文章主要給大家介紹了關(guān)于iOS開(kāi)發(fā)教程之登錄與訪客的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-04-04
ios開(kāi)發(fā) try-catch引起的野指針問(wèn)題排查
這篇文章主要為大家介紹了ios開(kāi)發(fā) try-catch引起的野指針問(wèn)題排查,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
淺談Xcode 開(kāi)發(fā)工具 XCActionBar
本文主要給大家簡(jiǎn)單講解了Xcode的開(kāi)發(fā)工具 XCActionBar的介紹與使用方法,非常的全面實(shí)用,有需要的小伙伴可以參考下。2015-11-11

