UIImage:如何获取网站标签图标 [英] UIImage: How to get website tab icon

查看:114
本文介绍了UIImage:如何获取网站标签图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个RSS阅读器,我需要为每个Feed获取favicon。例如,如果我的Feed是google.com,我想获得G图标并将其放入UIImage或其他内容。关于如何实现这一目标的任何想法?

I'm developing an RSS Reader and I need to get the favicon for each feed. For example, if my feed is google.com, I'd like to get the "G" icon and put it into a UIImage or something. Any ideas on how to achieve this?

推荐答案

最简单的方法是使用Google:

The easiest way to go would be to use Google:

NSString *myURLString = @"http://www.google.com/s2/favicons?domain=www.stackoverflow.com";
NSURL *myURL=[NSURL URLWithString: myURLString];
NSData *myData=[NSData dataWithContentsOfURL:myURL];

UIImage *myImage=[[UIImage alloc] initWithData:myData];

这应该有效。

你会只需要替换您要查询图标的域。

You would just have to replace the domain where you want to query your icon.

这篇关于UIImage:如何获取网站标签图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆