A few simple and practical tips for developing IOS _ios

Source: Internet
Author: User

Objective

This article documented the small knowledge points encountered in the development of iOS, as well as some tips, the following words not to say, to see the detailed introduction.

Tips 1:uibutton pictures and text by default is left and right, how to achieve the left-and-right arrangement?

Solution Tips:

Button.transform = Cgaffinetransformmakescale ( -1.0, 1.0);
Button.titleLabel.transform = Cgaffinetransformmakescale ( -1.0, 1.0);
Button.imageView.transform = Cgaffinetransformmakescale (-1.0, 1.0);


Tip 2: Set navigation bar transparency, title and Barbuttonitem opaque

[Self.navigationController.navigationBar setbackgroundimage:[uiimage new] forbarmetrics:uibarmetricsdefault];

Self.navigationController.navigationBar.translucent = YES;

Tip 3: Set the navigation bar Without Borders

Self.navigationController.navigationBar.shadowImage = [UIImage new];


Tip 4: Hide and display with the scrolling navigation bar of the view (one code)

Self.navigationController.hidesBarsOnSwipe = Yes;


Tip 5: Simple and easy to get the current time stamp

 Time stamp
 time_t now;
 Time (&now);
 NSLog (@ "---%ld", now);

Tip 6: Set only the upper-left corner of the UIView and the rounded corner of the upper-right corner (four rounded corners can be selected)

 UIView *blueview = [[UIView alloc] Initwithframe:cgrectmake (MB, MB)];
 Blueview.backgroundcolor = [Uicolor bluecolor];
 [Self.view Addsubview:blueview]; 
 /* Set the enumeration parameter for fillet position
  uirectcornertopleft  = 1 << 0,
  uirectcornertopright = 1 << 1,
  Uirectcornerbottomleft = 1 << 2,
  uirectcornerbottomright = 1 << 3,
  uirectcornerallcorners = ~0UL
   */
 Uibezierpath *maskpath = [Uibezierpath bezierPathWithRoundedRect:blueView.bounds byroundingcorners: ( Uirectcornertopleft| Uirectcornertopright) Cornerradii:cgsizemake (20.0, 20.0)];
 Cashapelayer *masklayer = [Cashapelayer layer];
 Masklayer.frame = blueview.bounds;
 Masklayer.path = Maskpath.cgpath;
 BlueView.layer.mask = Masklayer;


Tip 7: Prevent users from copying cuts after loading UIWebView

The controller implements this method
-(BOOL) Canperformaction: (SEL) Action Withsender: (ID) sender
{
 if (action = = @selector (copy:) | |
  action = = @selector (paste:) | |
  Action = = @selector (cut:))
 {return
  NO;
 }
 return [Super Canperformaction:action Withsender:sender];
}

Tip 8: Jump controller Hide Tabbar a once and for all

Create a NAV base class rewrite Pushviewcontroller: The method is as follows:
-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated :(BOOL) Animated {

 viewcontroller.hidesbottombarwhenpushed = YES;

 [Super Pushviewcontroller:viewcontroller animated:animated];

}

Summarize

The above is the entire content of this article, I hope this article of these tips for your iOS developers can help, if you have questions you can message exchange. Small series will also be updated on the iOS related skills of the article, please continue to focus on the cloud habitat community.

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.