Example How to Use Buttons(UIButton) in XCode for iPhones

Button-Log-Off-icon An instance of the UIButton class implements a button on the touch screen. A button intercepts touch events and sends an action message to a target object when tapped. This class provides methods for setting the title, image, and other appearance properties of a button. Here is just a very simple example on how to use Buttons (UIButton).

UIButton *Button_Login = [UIButton buttonWithType:UIButtonTypeRoundedRect];         //set board
Button_Login.frame = CGRectMake(143, 50, 40, 30);                                   //position and size
Button_Login.backgroundColor = [UIColor clearColor];
[Button_Login setTitle:@"Login" forState:UIControlStateNormal];                      //set label text
Button_Login.titleLabel.font = [UIFont fontWithName:@"helvetica" size:12];           //set font and size
[Button_Login setBackgroundImage:[UIImage imageNamed:@"28.png"] forState:UIControlStateNormal];  //set background
[self.view addSubview:Button_Login];
[Button_Login addTarget:self action:@selector(Login_Judge) forControlEvents:UIControlEventTouchDown];  //tigger Login_Judge

Here is some others font name which you can use:

label.font = [UIFont fontWithName:@"Arial-BoldItalicMT" size:24];
/*Font name as below:
Font Family: American Typewriter
Font: AmericanTypewriter
Font: AmericanTypewriter-Bold
Font Family: AppleGothic
Font: AppleGothic
Font Family: Arial
Font: ArialMT
Font: Arial-BoldMT
Font: Arial-BoldItalicMT
Font: Arial-ItalicMT
Font Family: Arial Rounded MT Bold
Font: ArialRoundedMTBold
Font Family: Arial Unicode MS
Font: ArialUnicodeMS
Font Family: Courier
Font: Courier
Font: Courier-BoldOblique
Font: Courier-Oblique
Font: Courier-Bold
Font Family: Courier New
Font: CourierNewPS-BoldMT
Font: CourierNewPS-ItalicMT
Font: CourierNewPS-BoldItalicMT
Font: CourierNewPSMT
Font Family: DB LCD Temp
Font: DBLCDTempBlack
Font Family: Georgia
Font: Georgia-Bold
Font: Georgia
Font: Georgia-BoldItalic
Font: Georgia-Italic
Font Family: Helvetica
Font: Helvetica-Oblique
Font: Helvetica-BoldOblique
Font: Helvetica
Font: Helvetica-Bold
Font Family: Helvetica Neue
Font: HelveticaNeue
Font: HelveticaNeue-Bold
Font Family: Hiragino Kaku Gothic **** W3
Font: HiraKakuProN-W3
Font Family: Hiragino Kaku Gothic **** W6
Font: HiraKakuProN-W6
Font Family: Marker Felt
Font: MarkerFelt-Thin
Font Family: STHeiti J
Font: STHeitiJ-Medium
Font: STHeitiJ-Light
Font Family: STHeiti K
Font: STHeitiK-Medium
Font: STHeitiK-Light
Font Family: STHeiti SC
Font: STHeitiSC-Medium
Font: STHeitiSC-Light
Font Family: STHeiti TC
Font: STHeitiTC-Light
Font: STHeitiTC-Medium
Font Family: Times New Roman
Font: TimesNewRomanPSMT
Font: TimesNewRomanPS-BoldMT
Font: TimesNewRomanPS-BoldItalicMT
Font: TimesNewRomanPS-ItalicMT
Font Family: Trebuchet MS
Font: TrebuchetMS-Italic
Font: TrebuchetMS
Font: Trebuchet-BoldItalic
Font: TrebuchetMS-Bold
Font Family: Verdana
Font: Verdana-Bold
Font: Verdana-BoldItalic
Font: Verdana
Font: Verdana-Italic
Font Family: Zapfino
Font: Zapfino*/

You can find the UIButton Class Reference for more details. :)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed Follow us Follow us
You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply