zoukankan      html  css  js  c++  java
  • UIBotton UIlabel Ios 下拉框

    //下拉列表动画加载
    -(void)dropDownListAnimation
    {
        SchoolInHandAppDelegate *app = [[UIApplication sharedApplication]delegate];
        //每行的高度
        everyListHight = 30;
        listHight = userCountInFile*everyListHight;
        presstimes ++;
        if(_dropDownbackView ==nil)
        {
            _dropDownbackView = [[UIScrollView alloc]init];
            [_dropDownbackView autorelease];
        }
        _dropDownbackView.frame = CGRectMake(49, 180, 223, listHight);
        [self.view addSubview:_dropDownbackView];
        
        if(_dropDownListView==nil)
        {
            _dropDownListView = [[UIScrollView alloc]init];
            [_dropDownListView autorelease];
        }
        _dropDownListView.frame = CGRectMake(0, 0, 223, listHight);
        //_dropDownbackView.backgroundColor = [UIColor redColor];
        int i;
        int n = 0;
        //UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"listbg.png"]];
        for(i = 0; i<userCountInFile; i++)
        {
            UILabel *userTitleLabel = [[UILabel alloc]init];
            NSString *userNameStr = [[NSString alloc]init];
            userNameStr = [[app.moudle.userNameInFileList objectAtIndex:i]objectForKey:LOGIN_NAME];
            UIButton *usernamebutton = [UIButton buttonWithType:UIButtonTypeCustom];
            //[usernamebutton setTitle:userNameStr  forState:UIButtonTypeCustom];
            usernamebutton.frame = CGRectMake(0, 0+n, 223, everyListHight);
            [usernamebutton setImage:[UIImage imageNamed:@"listbg.png"]forState:UIControlStateNormal ];
            //usernamebutton.backgroundColor = color;
            
            userTitleLabel.frame = CGRectMake(8, 0, 215, everyListHight);
            userTitleLabel.text = userNameStr;
            userTitleLabel.textColor = [UIColor whiteColor];
            userTitleLabel.font = [UIFont systemFontOfSize:14];
            userTitleLabel.backgroundColor = [UIColor clearColor];
            
            //删除按键
            UIButton *delbutton = [UIButton buttonWithType:UIButtonTypeCustom];
            delbutton.frame = CGRectMake(183, 0, 40, everyListHight);
            [delbutton setImage:[UIImage imageNamed:@"del.png"]forState:UIControlStateNormal ];
            [delbutton setImage:[UIImage imageNamed:@"deled.png"]forState:UIControlStateSelected ];
            [delbutton addTarget:self action:@selector(deleteBtnPress:) forControlEvents:UIControlEventTouchUpInside];
           
            
            [usernamebutton addSubview:delbutton];
            [usernamebutton addSubview:userTitleLabel];
            [usernamebutton addTarget:self action:@selector(chooessUserName:) forControlEvents:UIControlEventTouchUpInside];
            [_dropDownListView addSubview:usernamebutton];
            n = n + everyListHight;
            usernamebutton.tag = i;
            delbutton.tag = i;
            //[userNameStr release];
        }
        //动画
        _dropDowAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
        if(presstimes%2 != 0)
        {
            _dropDowAnimation.fromValue = [NSNumber numberWithFloat:-listHight];
        }
        else 
        {
            _dropDownListView.frame = CGRectMake(0, -300, 223, listHight);
            
            _dropDowAnimation.fromValue = [NSNumber numberWithFloat:listHight];
        }
        _dropDowAnimation.toValue = [NSNumber numberWithFloat:0];
        //_dropDownListView.backgroundColor = [UIColor redColor];
        //x,y轴缩小到0.1,Z 轴不变
        //持续时间
        _dropDowAnimation.duration = 0.35;
        //重复次数
        _dropDowAnimation.repeatCount = 1;
        _dropDowAnimation.delegate = self;
        //设置_dropDownListView 的容量。
        [_dropDownListView setContentSize:CGSizeMake(185, listHight+20)];
        [_dropDownListView.layer addAnimation:_dropDowAnimation forKey:nil];
        [_dropDownbackView addSubview:_dropDownListView];
        
        //当第二次点的时候删除view。否则用户名就不能输入。
        if(presstimes%2 == 0)
        {
            [_dropDownbackView removeFromSuperview];
            _dropDownListView = nil;
            _dropDownbackView = nil;
        }
    }
  • 相关阅读:
    window.clipboardData(转载)
    动态添加样式(转载)
    IE6 IE7 FF的CSS Hack总结(转载)
    [轉貼] linux解壓 tar 命令
    [轉]用 snprintf / asprintf 取代不安全的 sprintf
    寫一個函數計算當參數為 n(n很大) 時的值 12+34+56+7……+n
    [轉]vi 與 vim 的指令整理
    MySQL和php採用UTF8的方法
    [轉]printf 引數說明
    [C] warning: ISO C90 forbids mixed declarations and code
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2674543.html
Copyright © 2011-2022 走看看