Code implementation for iPhone Development

Source: Internet
Author: User

IPhone DevelopmentThe implementation of the Code is the content to be introduced in this article. Should you be interested in it? This article describes how to create a jiugongge bucket. Let's take a look at the details. Many people in CocoaChina are asking, but it's actually very simple.ImageThe Code is as follows.

:

The core is the two methods:

 
 
  1. // Power by ieliwb.com
  2. -(Void) viewDidLoad {
  3. [Super viewDidLoad];
  4. NSArray * imageNames = [NSArray arrayWithObjects:
  5. @ "Ico_mobile.png ",
  6. @ "Ico_idcard.png ",
  7. @ "Ico_postcode.png ",
  8. @ "Ico_flight.png ",
  9. @ "Ico_translate.png ",
  10. @ "Ico_phone.png ",
  11. @ "Ico_car.png ",
  12. @ "Ico_health.png ",
  13. @ "Ico_bjxm.png", nil];
  14. UIButton * Btn;
  15. For (int I = 0; I <9; I ++ ){
  16. CGRect frame;
  17. Btn = [[UIButton buttonWithType: UIButtonTypeCustom] retain];
  18. [Btn setImage: [UIImage imageNamed: [imageNames objectAtIndex: I] forState: UIControlStateNormal]; // set the button Image
  19. Btn. tag = I;
  20. Frame. size. width = 59; // you can specify the coordinate and size of a button.
  21. Frame. size. height = 75;
  22. Frame. origin. x = (I % 3) * (59 + 32) + 40;
  23. Frame. origin. y = floor (I/3) * (75 + 24) + 40;
  24. [Btn setFrame: frame];
  25. [Btn setBackgroundColor: [UIColor clearColor];
  26. [Btn addTarget: self action: @ selector (btnPressed :) forControlEvents: UIControlEventTouchUpInside];
  27. [Self. view addSubview: Btn];
  28. [Btn release];
  29. }
  30. }
  31. // Response button event
  32. -(Void) btnPressed :( id) sender {
  33. UIButton * Btn = (UIButton *) sender;
  34. Int index = Btn. tag;
  35. Switch (index ){
  36. Case 0:
  37. If (mobileController = nil)
  38. MobileController = [[MobileController alloc] init];
  39. [Self. navigationController pushViewController: mobileController animated: YES];
  40. Break;
  41. // Several other controllers are similar
  42. }
  43. }

The following figure shows how to modify the jiugongge Background:

 
 
  1. - (void)loadView {  
  2.     UIImageView *contentView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];  
  3.     [contentView setImage:[UIImage imageNamed:@"subview_9_bg.png"]];  
  4.     [contentView setUserInteractionEnabled:YES];  
  5.     self.view = contentView;  
  6.     [contentView release];  

UINavigationBar backgroundImageThis can be achieved as follows:

 
 
  1. @implementation UINavigationBar (CustomImage)  
  2. - (void)drawRect:(CGRect)rect {  
  3.     UIImage *image = [UIImage imageNamed: @"top_bg.png"];  
  4.     [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];  
  5. }  
  6. @end 

Summary:IPhone DevelopmentThe content of code implementation of jiugongge has been introduced. I hope this article will help you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.