文章标题

来源:互联网 发布:java开发restful接口 编辑:程序博客网 时间:2024/06/06 01:18

dispatch_async(dispatch_get_global_queue(0, 0), ^{
//处理的耗时操作
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@”http://192.168.1.67:8080/img/luckgo_spxq.png“]];
//通知主线程刷新
dispatch_async(dispatch_get_main_queue(), ^{
UIImage *image = [UIImage imageWithData:data];
CGSize size = image.size;
CGFloat width = size.width;
CGFloat height = size.height;
CGFloat scale = height/width;

        CGFloat scaledWidth = SCREEN_WIDTH;        CGFloat scaledHeight = SCREEN_WIDTH * scale;        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, scaledWidth, scaledHeight)];        imageView.image = image;        [self.view addSubview:imageView];    });});
0 0
原创粉丝点击