Can any body tell me how can I set Image directly on UIView
?
Here is my code:
UIView *view=[[UIView alloc]init];
[view setImage:[UIImage imageNamed:@"image.png"]];
With Interface Builder it's pretty easy to add and configure a UIImageView. The first step is to drag the UIImageView onto your view. Then open the UIImageView properties pane and select the image asset (assuming you have some images in your project).
You can import images using the Image tool or by dragging and dropping them from Windows® Explorer. You can place images into 2D views only. Open the model view in which you want to place the image. Click Insert tab Import panel (Image).
Drag and drop image onto Xcode's assets catalog. Or, click on a plus button at the very bottom of the Assets navigator view and then select “New Image Set”. After that, drag and drop an image into the newly create Image Set, placing it at appropriate 1x, 2x or 3x slot.
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(x, y, width, height)];
[view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"a.png"]]];
Hope this is help you.
This is very simple to do. Try:
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(origin_x, origin_y, width, height)];
UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a.png"]];
[view addSubview:imageView];
[imageView release];
You can also play with the UIImageView
's frame property to move it around in your UIView
. Hope that Helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With