iOS notes (some common points of knowledge)

Source: Internet
Author: User

This is a few notes I made when I was doing a project in the company ....

1.iphone Development--Change the color of the dots in the Uipagecontrol

Pagecontrol.currentpageindicatortintcolor = [Uicolor blackcolor];

Pagecontrol.pageindicatortintcolor = [Uicolor Graycolor];


2.ios How to turn the status bar into white

[[UIApplication sharedapplication]setstatusbarstyle:uistatusbarstylelightcontent];

If not, please add View controller-based status bar appearance no in Info.plist

you can refer to http://beyondvincent.com/blog/2013/11/03/120-customize-navigation-status-bar-ios-7/


3. For example: Modify the navigation bar default title "Yi Yun Mei Printing" color and font

self. title=@ "Yi Yun Mei Printing";

self. navigationcontroller.navigationbar.titletextattributes=@{uitextattributetextcolor:[ Uicolor whitecolor],uitextattributefont:[uifont boldsystemfontofsize:]};


4. Set a fillet for the label

Label.layer.borderwidth=1.0f;

label.layer.cornerradius=5.0f;


5. Manual rotation of the status bar must implement the following method

-(BOOL) shouldautorotate

{

return NO;

}

-(Nsuinteger) supportedinterfaceorientations

{

return uiinterfaceorientationmaskportrait;

}


6. How to set only vertical screen display

Modify Info.plist inside Supportedinterfaceorientations Set Item to portrait on it, this setting is global.


7. Use Uicolor to show #f6f6f6 this traditional color converted to a decimal f6 of 240

Then Uicolor *color=[uicolor colorwithred:255.0 Green: +/255.0 Blue:240 /255.0 Alpha:1];


8. Create categories, extensions, agreements, empty files

Cmd+n Select the type of objective-c file--File type (class, extension, protocol, empty file) inside iOS source


9. Convert the view to a picture

Convert a view to a picture

Uigraphicsbeginimagecontext (oppositeImageView.bounds.size);

[Oppositeimageview.layer Renderincontext:uigraphicsgetcurrentcontext ()];

UIImage *oppositeimg=uigraphicsgetimagefromcurrentimagecontext ();

Uigraphicsendimagecontext ();


10. Drag effect for picture view

-(void) Viewdidload {

[Super Viewdidload];

//Create a picture view

ImageView = [[Uiimageview alloc] Initwithframe:cgrectmake (+, +, +) ];

imageview.userinteractionenabled=YES;

Imageview.image=[uiimage imagenamed:@ "Ad_1"];

//panning gestures

Uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc] Initwithtarget: Self action:@selector (panaction:)];

[ImageView Addgesturerecognizer:pan];

[self. View Addsubview:imageview];

}

Drag events for panning gestures

-(void) Panaction: (Uipangesturerecognizer *) pan

{

Cgpoint point=[pan Translationinview:self. view];

Pan.view.center=cgpointmake (Pan.view.center.x+point.x, PAN.VIEW.CENTER.Y+POINT.Y);

[Pan Settranslation:cgpointzero InView:self. view];

}

11. Pictures can respond to events, such as Uitextview added to the picture can be dragged.

backgrondimage.userinteractionenabled=YES;

iOS notes (some common points of knowledge)

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.