Reputation: 687
Is it possible to add an image in the UIView with specific coordinates? If so, anyone who is keen on explaining how to?
Upvotes: 0
Views: 1942
Reputation: 7663
You need to create an UIImageView and set it's frame to the desired coordinate.
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:<#imageName#>]];
imageView.frame = CGRectMake(<#x#>, <#y#>, <#width#>, <#height#>);
[yourViewController.view addSubView:imageView];
Let me know if this works for you.
Upvotes: 4
Reputation:
Yes, you have either to draw the image in -(void)drawRect:(CGRect)aRect;
, by subclassing UIView
, or to add an UIImageView
as a subview of the main view, displaying the image.
Have a look on these :
UIImageView Class Reference.
UIView
Upvotes: 0
Reputation: 54593
Something like this?
UIImageView *myImage = [[UIImageView alloc] initWithImage:someImage];
myImage.frame = CGRectMake(40, 40, myImage.frame.size.width, myImage.frame.size.height);
[myView addSubview:myImage];
That'll add an image, contained in an image view, at specific coordinates.
Upvotes: 1