2

I would like to create something like this:

enter image description here

I would like to place an UITextField with an UIButton into one grey frame, and I would like the button's border to be contained by this grey frame.

Please somebody show me some sample code for this!

Thx!

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
viplezer
  • 5,519
  • 1
  • 18
  • 25
  • I have tried to build it in IB, put up an UIView and put the 2 other view onto it, but I can't find the good attributes. Sorry for you had to read my question... – viplezer Mar 27 '12 at 08:42
  • And I didn't write this post because I don't want to try or I'm lazy or it is better for me if I use the code of somebody else or etc. I write it because I don't know how should I do it, and I thought that a place where people come to ask help, will be a good place... – viplezer Mar 27 '12 at 08:54

2 Answers2

3

1. Use a UIImageView of required rect. Set the background image to the gradient gray colour image.

 UIImageView*myImageView=[[UIImageView alloc] initWithFrame:yourFrame];
 [myImageView setImage:[UIImage imageNamed:@"grayBackground.png"];
 [self.view addSubview:myImageView];

2. Use a round rect. UITextField make it a subview of the image view. Use a place holder as "Write a reply..." make it a subview to your imageview.

UITextField*myField=[[UITextField alloc] initWithFrame:yourRect];
[myField setBorderStyle:UITextBorderStyleRoundedRect];
[myField setPlaceholder:@"Write a reply..."];
[myImageView addSubview:myField];

3. Use a UIButton with type Custom and the send image as its background image, make it a subview to your imageview.

UIButton*myButton=[UIButton buttonWithType:UIButtonTypeCustom];
[myButton setFrame:yourRect]
[myButton setBackgroundImage:[UIImage imageNamed:@"sendImage.png"] forState:UIControlStateNormal];
[myImageView addSubView:myButton];
iNoob
  • 3,364
  • 2
  • 26
  • 33
0

Simple way is to create title bar with grey background and delete the title.and place textfield and button which u want to place it.configure the size and button outside the title bar and drag it to the title bar..u'll get like the image which u have got.

enter image description here

Vishnu
  • 2,243
  • 2
  • 21
  • 44