id path = @"https://www.google.com/images/logos/ps_logo2.png";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
// UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
UIImage *img =[ UIImage imageWithData:data];
UIImageView *imView = [[UIImageView alloc] initWithImage:img];
[self.view addSubview:imView ];
//在cocos2d
id path = @"https://www.google.com/images/logos/ps_logo2.png";
NSURL *imgUrl = [NSURL URLWithString:path];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
CCTexture2D *tt2d = [[CCTexture2D alloc] initWithImage:image];
CCSprite *sp = [CCSprite spriteWithTexture:tt2d];
[self addChild: sp];
沒有留言:
張貼留言