51.小项目:应用管理 Part1

 

 

---------- ViewController.m ----------

 

#import "ViewController.h"

#import "CZApp.h"

#import "CZAppCell.h"

 

@interfaceViewController ()<CZAppCellDelegate>

 

@property (nonatomic, strong) NSArray *apps;

 

@end

 

@implementation ViewController

 

- (BOOL)prefersStatusBarHidden

{

    returnYES;

}

 

- (NSArray *)apps

{

    if (_apps == nil)

    {

        NSArray *dictArray = [NSArrayarrayWithContentsOfFile:[[NSBundlemainBundle] pathForResource:@"apps_full.plist"ofType:nil]];

        

        NSMutableArray *appArray = [NSMutableArrayarray];

        for (NSDictionary *dict in dictArray)

        {

            CZApp *app = [CZApp appWithDict:dict];

            [appArray addObject:app];

        }

        _apps = appArray;

    }

    return _apps;

}

 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    returnself.apps.count;

}

 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    CZAppCell *cell = [tableView dequeueReusableCellWithIdentifier:@"app"];

    cell.delegate = self;

    cell.app = self.apps[indexPath.row];

    return cell;

}

 

- (void)appCellDidClickedDownloadBtn:(CZAppCell *)cell

{

    CZApp *app = cell.app;

    UILabel *label = [[UILabel alloc] init];

    label.text = [NSString stringWithFormat:@"成功下载%@", app.name];

    label.font = [UIFont systemFontOfSize:12];

    label.textAlignment = NSTextAlignmentCenter;

    label.textColor = [UIColor whiteColor];

    label.backgroundColor = [UIColorblackColor];

    label.frame = CGRectMake(0, 0, 150, 25);

    label.center = CGPointMake(160, 240);

    label.alpha = 0.0;

    label.layer.cornerRadius = 5;

    label.clipsToBounds = YES;

    [self.view addSubview:label];

    [UIViewanimateWithDuration:0.5animations:^{

        label.alpha = 0.5;

    } completion:^(BOOL finished) {

        [UIViewanimateWithDuration:0.5delay:0.5options:UIViewAnimationOptionCurveLinearanimations:^{

            label.alpha = 0.0;

        } completion:^(BOOL finished) {

            [label removeFromSuperview];

        }];

    }];

}

 

@end

转载于:https://www.cnblogs.com/lixiang2015/p/4727402.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值