Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding UILabel to UIImageView

Is there a way where i could add a UILabel on top of a UIImageView programmatically ?

So finally there should be a label displayed on top of a Image.

like image 355
sharon Avatar asked Dec 26 '11 16:12

sharon


2 Answers

UIImageView is a subclass of UIView so you can add any UI object onto it.

UILabel  *xlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
    xlabel.text = @"xxx";

[myImageView addSubview:xLabel];
like image 53
Cyprian Avatar answered Sep 28 '22 08:09

Cyprian


As simple as

[imageView addSubview:yourLabel];
like image 22
Ecarrion Avatar answered Sep 28 '22 09:09

Ecarrion