iOS 简单实现下拉列表框
来源:互联网 发布:mysql数据库基础 编辑:程序博客网 时间:2024/05/12 09:12
iOS 简单实现下拉列表框
import “LianXIViewController.h”
@interface LianXIViewController ()
// 定义视图作为下拉列表框内容
@property (nonatomic, retain)UIView * myView;
@end
@implementation LianXIViewController
(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.self.view.backgroundColor = [UIColor blueColor];
// 首先创建一个 Button 按钮 点击弹出下拉列表框
UIButton * myButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
// 给 按钮设置位置
myButton.frame = CGRectMake(100, 100, 100, 30);
// 设置 按钮名称
[myButton setTitle:@”下拉列表框” forState:(UIControlStateNormal)];
// 给按钮添加背景颜色
myButton.backgroundColor = [UIColor orangeColor];
// 添加按钮点击方法
[myButton addTarget:self action:@selector(myActionButton) forControlEvents:(UIControlEventTouchUpInside)];
// 将按钮加在主视图
[self.view addSubview:myButton];// 思路:
// 初始化下拉列表框 位置 在Button 下方 这个位置可以随便设在想要它出现的地方
// 现将 alpha 设置为0 此时这个View 不显示 点击Button 的时候再判断透明度 alpha
self.myView = [[UIView alloc] initWithFrame:(CGRectMake(100, 140, 100, 100))];
// 设置背景颜色
self.myView.backgroundColor = [UIColor redColor];
// 设置两个 UILabel 添加到 下拉列表视图中 这个视图可以看做平常视图 随便使用
UILabel * myLabel1 = [[UILabel alloc] initWithFrame:(CGRectMake(0, 0, 100, 40))];
myLabel1.text = @”大师兄”;
UILabel * myLabel2 = [[UILabel alloc] initWithFrame:(CGRectMake(0, 60, 100, 40))];
myLabel2.text = @”二师兄”;
// 将两个UILabel 添加到 myView 上
[self.myView addSubview:myLabel1];
[self.myView addSubview:myLabel2];
// 设置 myView 的透明度 当为 0 的时候彻底透明 也可以理解为隐藏
self.myView.alpha = 0;
// 将myView 添加到 主视图上
[self.view addSubview:self.myView];
}
// 实现点击方法
- (void)myActionButton
{
NSLog(@”sldjflskjdf”);
// 思路: 判断myView 的 alpha 属性是否为 0
// 当为 0 的时候说明掩藏 则更改为1
// 当为 1 的时候说明显示 则更改为0
if (self.myView.alpha == 0) {
self.myView.alpha = 1;
} else {
self.myView.alpha = 0;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// 介绍到此结束 多谢各位看官观赏
- iOS 简单实现下拉列表框
- 下拉列表简单实现跳转
- 下拉列表框实现
- 下拉列表框实现
- WPF-002 下拉列表的简单实现
- WPF:下拉列表的简单实现
- 【IOS功能实现】之:下拉列表
- IOS UITableView Section下拉列表实现
- 【IOS功能实现】之:下拉列表
- iOS study Day18-下拉列表框
- iOS 创建下拉列表
- iOS下拉列表
- ios自定义下拉列表
- iOS开发 下拉列表
- iOS 下拉列表
- Android中Spinner下拉列表(简单layout.xml,ArrayAdapter和自定义Adapter实现)及下拉框提示prompt问题
- 关于PropertyGrid 下拉列表,C#实现,其实比较简单
- mysql+php select 下拉列表树的简单实现
- android沉浸式状态栏实现
- eclipse web helloworld
- lightoj 1203(凸包)
- c++ 学习的资源汇总
- 数电和FPGA中的触发器-20151102
- iOS 简单实现下拉列表框
- [ecshop 调试 ]ecshop中的 debug_mode 是在哪里定义的 查看sql日志 输出错误 显示debug
- Spark 入门之一:CentOS 6.5 下Spark 1.4 的安装以及配置
- Integer.parseInt()和Integer.valueOf()有什么区别
- 网站如何记录访客的个人信息?
- lesson18 Aliasing
- 关于文件上传的学习心得
- 不借用临时变量交换两个整数的值
- Java多线程的实现方法