Custom Look And Feel of a text field in iOS - iphone

I'm a beginner with Objective-C and have a question regarding creating a custom look and feel text box. I want to be able to create a text box area that has, for example a header with a label and different background color etc. where the text input appears. How does one go about doing such a thing in Objective-C? Is it a matter of just creating a custom class that has a UILabel with specific coordinates on top of the UITextBox? Let me know if someone can point me in the right direction. Thanks.

One option is to create a custom view that contains a UITextField and UILabel as sub-views. After that, the view can be re-used.
I highly recommend reading the View Programming Guide # Apple: http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/ViewPG_iPhoneOS/Introduction/Introduction.html
A related post on creating an aggregate custom view: .Net UserControl XCode equivalent
Here's one tutorial on creating a custom view:
http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view
You can also look at how other custom controls are built. Many of the controls at cocoacontrols.com are open sourced: http://www.cocoacontrols.com/

Use layer property of text field like
#property (nonatomic,weak)IBOutlet UITextfield *email;
so in implementation file or view did load method
self.email.layer.backgroundColor = [uicolor orangeColor];

Related

Material TextView via Storyboard?

Is there a way to implement the material TextView via the storyboard? The example only shows via programmatically. Please help?
The answer is actually quite simple, and I just discovered it myself while attempting to do what you asked. All you need to do is go to the identity inspector of whatever object you want to use as a material object, then in the "class" field, put the ID of whatever material class you're using (i.e. "RaisedButton"), and you're all set! Hope this helps!
The tricky part about using a TextView in storyboards with the Material Text class that does pattern detection is the instantiation part. Storyboards take care of the initialization for you, which makes it difficult to update the textContainer layer, as it needs to be passed to the TextView when initialized. I am looking into this to see if there is a solution.
If you look at the source of TextField, you will see that it is a subclass of UITextField. This means that you can just change the class of a UITextField object that you drop onto your Storyboard, and then do any other configuration in code.

xcode : how should we display large number of Label & buttons in Tabular form?

Actually I am having problem in displaying around 10-15 rows of Label & Button controls in view. Then I used UIScroll view to achieve this but that corrupt the appearance of design.
As you can see the generated output is different from the appearance in the Xcode while developing.
Please guid me what should be done to render proper design?
Thanks
Ashish
You should use UITableView.
Create custom UITableViewCell.
Your each row will contain one UILabel and UIButton.
You can check.
See the attached image :
Create a custom UITableViewCell and use that one in your code.
And in cellForRowAtIndexPath assign values to your cell properties.
Refer this Apple sample code
Also there are so many examples over net, search for custom UITableViewCell and you will find various tutorials out there.
Here is one more third-party tutorial link:
Hope this helps.

Change property of a button programmatically

I am working on another person's code. He has created some UIButtons in a UIView in the interface builder(not programmatically).
But now the UI has changed slightly. When the view loads, based on some conditions, some buttons have to be disabled/enabled. I am a bit confused about, whether to alter the code by creating buttons dynamically and disable the buttons based on conditions, or is there any other way like referring the button by tag and changing its property. Sounds like a silly question, I am still working on improving my basic skills in Iphone app development.
Create an IBOutlet to the UIButton, then you can do things like:
myButton.enabled = NO; // or YES
myButton.hidden = NO; // or YES
You would need to create an IBOutlet using interface building which will give you a reference to the button in your nib file. From there you can modify the parameters on the button which was loaded.

How to set different width of elements [iPhone-dev]

Look this pic:
The usernames are UIButton. How can I put a UILabel (with the comment text) just after the UIButton (with the username) ?
The UIButton username's is dynamic. How can I do this?
That looks like a UITableView, if that's the case you should subclass UITableViewCell. If it isn't, I would
consider making it one
build a container class that (or make your subclassed UITableViewCell such that it) contains both a UIButton and a UILabel and dynamically position the text inside the label according to the size of the button (for instance, adding the right number of spaces to the beginning of the text).
You're going to have to use Core Text or web views to achieve this. There's really not a super easy way to do this. It's simple enough to place view next to each other based on their calculated sizes, but to have text wrap to multiple lines with embedded font style variations and attachments (i.e., images), you're going to have to read up on Core Text or use XHTML in web views.

Floating a UILabel above OpenFlow

How do you get a UILabel to float above Alex Fajkowski's implementation of CoverFlow called OpenFlow?
Ok I've figured it out. I just had to use bringSubviewToFront with the UILabel.
Thanks to everybody who answered.
Make an OpenFlow instance and a UILabel instance subviews of a parent view, placing the label atop with flow view using -insertSubview:atIndex:, -addSubview: or similar e.g.:
[self.view addSubview:myOpenFlow];
[self.view addSubview:myLabel];
To answer the second question, try this: edit the AFOpenFlowView in IB and add the label view as a subview of that wherever you want it to appear, then set the attributes on the view to Hidden if you don't want it to appear by default. Create an IBOutlet for the label view in your controller so you can easily manipulate it, such as setting hidden to show in order to show it. I'm not familiar with open flow so I'm not sure if it will programmatically create a subview that will obscure your label. If so you may need to use the outlet to move it to the front using UIView methods.
The Openflow example code shows a perfect demonstration of this. Alex adds an info button in the top right of the openflow view using interface builder. This is exactly what you are asking for.
I would add that if you can't understand what is going on from the example code, you should look at more code examples from Apple demonstrating simple UIView usage.
It's not so easy because the label name has to change for each picture. We have to work with index, and with event.. move.. tap.. selected...I'm working on too !