开发者

How to add a "play" icon on top of UITableviewCell imageView?

I have a tableview witch display video thumbnails. I would like to add/overlay a "play" icon开发者_高级运维 on top of the thumbnails. How to add this icon on all my thumbnails?


Add a custom button over your video thumbnail image with a transparent play png. Doing this will also allow you to hook that custom play button up to an action that could allow the user to play the video.


Here's what I do for my app:

UIImage *play = [UIImage imageNamed:@"play1.png"];
self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.playButton setImage:play forState:UIControlStateNormal];

[self.playButton addTarget:self 
                    action:@selector(playVideo) 
          forControlEvents:UIControlEventTouchUpInside];

Something that drove me nuts: Be sure to use a png NOT named "play.png"!


Agree withWrightsCS. You may want to seal your thumbnail into a separate class (let's say, a new subclass of UIView). And you customize it and put an transparent play icon on top of it.

Then you go back to you tableview's cell's class, and hook up that new thumbnail class with an action you want it to trigger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜