UIImage: How to get website tab icon

后端 未结 3 1440
一整个雨季
一整个雨季 2021-02-09 22:59

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 so

3条回答
  •  执笔经年
    2021-02-10 00:00

    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];
    

    That should work.

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

提交回复
热议问题