My Blog List

Tuesday, June 14, 2011

Study Notes: Syntax, Picking Apart the UIColor example

Study Notes: Syntax UIColor example



* Notice there are examples linked from frameworks class documentation. Studying these has been suggested in class and by Goldstein for learning
…..
What the following

   theTextField.textColor    =[UIColor blueColor];

seems to boil down to is

…. Set the textColor attribute (property) of my ‘theTextField’ ivar to be BLUE.


And here are all the details I went through to figure that out
….
I want to better understand this line of code from page 236

    theTextField.textColor =[UIColor blueColor];

“theTextField”

·    is a pointer I defined in the interface file associated with this implementation file.

@interface SettingsViewController : UIViewController {
    <SettingsViewControllerDelegate> delegate;
    float                       sliderValue;
    IBOutlet  UITextField   *theTextField;

·    The pointer is of type UITextField, a frameworks class
·    The part that follows theTextField uses dot notation
o     I THINK textColor is an instance method associated with UITextField



Let’s see if I can figure that out

·     option+ command on UITextField
·     follow link to ()delegate Protocol

NO DICE NO REFERENCE TO textColor


Overview
A UITextField object is a control that displays editable text and sends an action message to a target object when the user presses the return button. You typically use this class to gather small amounts of text from the user and perform some immediate action, such as a search operation, based on that text.
In addition to its basic text-editing behavior, the UITextField class supports the use of overlay views to display additional information (and provide additional command targets) inside the text field boundaries. You can use custom overlay views to display features such as a bookmarks button or search icon. The UITextField class also provides a built-in button for clearing the current text.
A text field object supports the use of a delegate object to handle editing-related notifications. You can use this delegate to customize the editing behavior of the control and provide guidance for when certain actions should occur. For more information on the methods supported by the delegate, see the UITextFieldDelegate protocol.


Go back up a level looking for textColor (some kind of method I think….)

It is a property of the UITextFieldClass. Don’t quite understand that. I know I use the property declaration to substitute for accesors. Well I least I see it that is something



OK back to

    theTextField.textColor =[UIColor blueColor];

I know that [] syntax means that I’m messaging an object. “Many methods in UIKit require you to specify color data using a UIColor object, and for general color needs it should be your main way of specifying colors. “
 So I’m messaging the UIColor class from the blueColor method.

I guess that I’m saying…. Set the textColor attribute (property) of my ‘theTextField’ ivar to be BLUE.





Understanding UIColor use


·     option+ command on UIColor to get documention

Overview
A UIColor object represents color and sometimes opacity (alpha value). You can use UIColor objects to store color data, and during drawing you can use them to set the current fill and stroke colors.
Many methods in UIKit require you to specify color data using a UIColor object, and for general color needs it should be your main way of specifying colors. The color spaces used by this object are optimized for use on iOS-based devices and are therefore appropriate for most drawing needs. If you prefer to use Core Graphics colors and color spaces instead, however, you may do so.
Most developers should have no need to subclass UIColor. The only time doing so might be necessary is if you require support for additional colorspaces or color models.


·     UIColor is the class
UIColor Class Reference
Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Declared in
UIColor.h
UIInterface.h
·      
·     blueColor is a class method assoc. with UIColor
blueColor
Returns a color object whose RGB values are 0.0, 0.0, and 1.0 and whose alpha value is 1.0.
+ (UIColor *)blueColor
Return Value
The UIColor object.
Availability
·                       Available in iOS 2.0 and later.

No comments:

Post a Comment