sharon
sharon

Reputation: 580

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.

Upvotes: 9

Views: 7271

Answers (2)

Cyprian
Cyprian

Reputation: 9453

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

Upvotes: 12

Ecarrion
Ecarrion

Reputation: 4950

As simple as

[imageView addSubview:yourLabel];

Upvotes: 6

Related Questions