I want to add a dynamic image in the UITableView's tableHeaderView part.
For that i am writing following code :
UIImageView *myImageView = [[UIImageView alloc]initWithFrame: CGRectMake(0.0f,
0.0f,
320.0f,
44.0f)];
self.tableView.tableHeaderView = myImageView;
[myImageView release];
With this code i am getting image in my screen, but with stretched view.
Now i want to set that image at the particular corner of HeaderView of table.
Anyone have any solution then please help me..
Thanks in advance..
Add your UIImageView to a regular container UIView and place it inside that.
Related
I am developing an app where I need to put a UITextView for the large text. I have a background image of size 180X89(same as UITextView frame size). When put the image behind the UITextView, everything appears good however, when the user hits the text area and keyboard appears, the cursor appears just outside the edge of the image.
I want the cursor to be appeared in textbox.
Code for getting UITextview
CGRect textViewFrame = CGRectMake(125.0f, 155.0f, 180.0f, 90.0f);
UITextView *textView = [[UITextView alloc] initWithFrame:textViewFrame];
textView.returnKeyType = UIReturnKeyDone;
textView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: #"textbox.png"]];
textView.delegate = self;
[self.view addSubview:textView];
Try this:
UIImage *bgImage = [UIImage imageNamed:#"textbox.png"];
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:bgImage];
CGRect textViewFrame = CGRectMake(125.0f, 155.0f, 180.0f, 90.0f);
bgImageView.frame = textViewFrame;
UITextView *textView = [[UITextView alloc] initWithFrame:textViewFrame];
textView.returnKeyType = UIReturnKeyDone;
textView.delegate = self;
[self.view addSubview:bgImageView];
[self.view addSubview:textView];
Or something like it.
There is very simple approach. Just use UIImageView behind the TextView and set UITextView Background color as clear color.
What you can do in such situations is to make the size of the UITextView a bit smaller so that it just comes in ur background image and also give the UITextView a corner radius using the framework <QuartzCore> like textview.layer.cornerRadius = 10; (import the header for the framework). This approach would also give the UITextView edges a bit of roundness to make it look like the image u provided above.
So, in short add the UIImageView then add the UITextView above it and make the background of the textview as clearcolor . Hope this helps !!! :)
Add UIImageView on your view, Then add UITextView on UIImageView with inner frame of
CGPointMake(10,10) as Origin
and CGSizeMake(imageView.frame.size.width - 20.0, imageView.frame.size.hieght - 20.0) as Size of textView.
I am developing an application in which I am using one UIImageView and adding one rectangle image to that UIImageView. I am getting some float value from another calculation like 67.4 and I need to place one green image on the 67.4 part of rectangle UIImageView. So please tell me how can I fill that green image onto that UIImageView ?
You can make a "rectangle", i.e. a UIView and color it as you wish. Then add it to your image view.
UIView *greenRect = [[UIView alloc] initWithFrame:
CGRectMake(67.4, 67.4, width, height)];
greenRect.backgroundColor = [UIColor greenColor];
[imageView addSubview:greenRect];
Is it possible to add an image in the UIView with specific coordinates?
If so, anyone who is keen on explaining how to?
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.
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.
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
I'm trying to insert one more image in my UIScrollView. The problem is: all my old content is still scrollable, but this image stay static in the top of the page. Does anybody know a solution?
Code:
- (void)viewDidLoad {
CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f);
myImage = [[UIImageView alloc] initWithFrame:myImageRect];
UIImage * img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:#"www.somelink.com"]]];
myImage.image = img;
myImage.opaque = YES; // explicitly opaque for performance
[scrollView addSubview:myImage];
[myImage release];
}
Regards.
I'm guessing that your "old content" is encapsulated in a view and it's that view that is your UIScrollView's subview for content. If that's the case, you should add your new image to that "contentView", adjust its frame and update the scrollview's contentSize based on the new width and height of the content view.
If my guess is wrong, could you please post the code showing how the UIScrollView is created and how the "old content" is added to it?
You might also find this sample code from Apple useful with regard to the layout of subviews of a UIScrollView. (see the - (void)layoutScrollImages method).
I am developing a software and in it I am making a new file, which is subclass of UIViewController, when I do use UIImageView, then there is little border remaining in it, what should I do so that my image should cover all area around it,
my coding of UIImageView in ViewDidLoad is
UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: #"frontnew.png"]];
view.frame = CGRectMake(0, 0, 320, 415);
[self.view addSubview:view];
now what should I do ????
If I increase height and width then it will increase from two sides, not all ???
you should set imageview property as scalltoFit
May be it can help you