IOS添加控制項

來源:互聯網
上載者:User

標籤:

        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;


 

}

 

 

IOS添加控制項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.