zoukankan      html  css  js  c++  java
  • IOS添加控件

            YJQApp *appInfo =self.apps[i];
            
            
            //.添加图片
            UIImageView * iconView = [[UIImageView alloc]init];
            CGFloat iconW= 22;
            CGFloat iconH =33;
            CGFloat iconX =(appW-iconW)*0.5;
            CGFloat iconY=0;
            iconView.frame=CGRectMake(iconX, iconY, iconW, iconH);
            
            iconView.image = [UIImage imageNamed:appInfo.icon];
            [appView addSubview:iconView];
            
            //.添加文字
            UILabel * nameLabel =[[UILabel alloc] init];
            CGFloat nameW = appW;
            CGFloat nameH = 20;
            CGFloat nameX = 0;
            CGFloat nameY = iconY+iconH;
            nameLabel.frame =CGRectMake(nameX, nameY, nameW, nameH);
            
            nameLabel.text=appInfo.icon;
            
            nameLabel.font =[UIFont systemFontOfSize:13];
            
            nameLabel.textAlignment = NSTextAlignmentCenter;
            
            [appView addSubview:nameLabel];
            
            //. 添加按钮
            UIButton * downloadBtn =[[UIButton alloc]init];
            CGFloat downloadX=12;
            CGFloat downloadY=nameY+nameH;
            CGFloat downloadW=appW-2*downloadX;
            CGFloat downloadH=20;
            downloadBtn.frame = CGRectMake(downloadX, downloadY, downloadW, downloadH);
            
            //设置默认背景
            UIImage * normalImage = [UIImage imageNamed:@"cc"];
            [downloadBtn setBackgroundImage: normalImage forState:UIControlStateNormal];
            
            
            //设置高亮背景
            UIImage * highImage =[UIImage imageNamed:@"cc"];
            [downloadBtn setBackgroundImage:highImage forState:UIControlStateHighlighted];
            
            //设置文字
            [downloadBtn setTitle:@"cc" forState:UIControlStateNormal];
            
            //设置文章字体
            downloadBtn.titleLabel.font=[UIFont systemFontOfSize:13];
            
            [appView addSubview:downloadBtn];



    - (NSArray *)apps{

        if(_apps==nil){

            //获取plist文件 全路径

            NSString * path = [[NSBundle mainBundle] pathForResource:@"app.plist" ofType:nil];

            NSArray * dicArray =[NSArray arrayWithContentsOfFile:path];

            NSMutableArray * appAarry =[NSMutableArray array];

           for(NSDictionary * dic  in dicArray){
                YJQApp * app = [YJQApp appWithDict:dic];
    
    

                 [appAarry addObject:app];

    
    

            }

    
    

            _apps = appAarry;

    
    

        }

    
    

        return _apps;

    
    

    }

     
  • 相关阅读:
    vue 报错./lib/html5-entities.js, this relative module was not found
    vuex 实现vue中多个组件之间数据同步以及数据共享。
    vue 使用Slot 分发内容 学习总结。
    pyftplib中文乱码问题
    Django对postgresql数据库进行分组聚合查询
    ubuntu16.04 一键安装nginx-rtmp
    python处理RSTP视频流
    百度人脸注册/搜索测试
    任何情况下,服务端都不能报500错误
    Django自定义指令+mq消息队列的使用
  • 原文地址:https://www.cnblogs.com/yangjingqi/p/4889097.html
Copyright © 2011-2022 走看看