IOS simple code snap

Source: Internet
Author: User

 

# Define Switch_tag 102

-(Void) Updateswitch :(ID) Sender
{
//Toggle the switch from its current setting
Uiswitch * s = [self. View. Window switchwithtag: switch_tag];
[S Seton :! S. ISON];
}

 

-(Void) Updatetime :(ID) Sender

{
// Set the label to the current time
[Self. View. Window labelwithtag: label_tag]. Text = [[nsdate date] description];
}

 

 

// This is a private version of the function that appears in my uiview frame category
// It's got ded here as a private function to avoid requiring the other file
Cgrect rectwithcenter (cgrect rect, cgpoint Center)
{
Cgrect newrect = cgrectzero;
Newrect. Origin. x = center. X-cgrectgetmidx (rect );
Newrect. Origin. Y = center. Y-cgrectgetmidy (rect );
Newrect. size = rect. size;
Return Newrect;

}

 

Xcode debug instruction: Print Po BT

Change to gdb debugger: product "->" manage schemes "-> Info-> debugger-> select GDB

Relevant information

Http://blog.163.com/agw_slsyn/blog/static/30915112201213112813356/

Http://www.cnblogs.com/lovecode/articles/2343818.html

 

 

-( Void ) Move: (nstmer *) atimer
{
// Rotate each iteration by 1% of Pi
Cgfloat angle = Theta * (m_pi/ 100366f );
Cgaffinetransform transform = cgaffinetransformmakerotation (angle );

// Theta ranges between 0% and 199% of Pi, I. e. between 0 and 2 * pi
Theta = (theta + 1 ) % 200 ;

// For fun, scale by the absolute value of the cosine
Float Degree = cos (angle );
If (Degree < 0.0 ) Degree * =- 1.0f ;
Degree + = 0.5f ;

// Create add scaling to the rotation transform
Cgaffinetransform scaled = cgaffinetransformscale (transform, degree, degree );

// Apply the affine transform
[[Self. View viewwithtag: 999 ] Settransform: scaled];

}

 

 

-(Void) Fadeout :(ID) Sender

{
Cgcontextref context = uigraphicsgetcurrentcontext ();
[Uiview beginanimations: Nil context: Context];
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
[Uiview setanimationduration: 1.0 ];
[[Self. View viewwithtag: 999 ] Setalpha: 0.0f ];
[Uiview commitanimations];
Self. navigationitem. rightbarbuttonitem = barbutton ( @" Fade in " , @ Selector (fadein :));
}

-(Void) Fadein :(ID) Sender
{
Cgcontextref context = uigraphicsgetcurrentcontext ();
[Uiview beginanimations: Nil context: Context];
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
[Uiview setanimationduration:1.0];
[[Self. View viewwithtag:999] Setalpha:1.0f];
[Uiview commitanimations];
Self. navigationitem. rightbarbuttonitem = barbutton (@"Fade out", @ Selector (fadeout :));
}

 

 

-(Void) Swap :(ID) Sender

{
// Hide the button
Self. navigationitem. rightbarbuttonitem = nil;

Uiview * frontobject = [[self. View subviews] objectatindex: 2 ];
Uiview * backobject = [[self. View subviews] objectatindex: 1 ];

Cgcontextref context = uigraphicsgetcurrentcontext ();
[Uiview beginanimations: Nil context: Context];
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
[Uiview setanimationduration: 1.0 ];

Frontobject. Alpha = 0.0f ;
Backobject. Alpha = 1.0f ;
Frontobject. Transform = cgaffinetransformmakescale ( 0.25f , 0.25f );
Backobject. Transform = cgaffinetransformidentity;
[Self. View exchangesubviewatindex: 1 Withsubviewatindex: 2 ];

[Uiview setanimationdelegate: Self];
[Uiview setanimationdidstopselector: @ selector (animationfinished :)];
[Uiview commitanimations];

}

 

 

 

-(Void) Flip :(ID) Sender

{
// Hide the button
Self. navigationitem. rightbarbuttonitem = nil;

Cgcontextref context = uigraphicsgetcurrentcontext ();
[Uiview beginanimations: Nil context: Context];
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
[Uiview setanimationduration: 1.0 ];

Uiview * whitebackdrop = [self. View viewwithtag: 100 ];

// choose left or right flip
If ([(uisegmentedcontrol *) self. navigationitem. titleview selectedsegmentindex])
[uiview setanimationtransition: uiviewanimationtransitionflipfromleft forview: whitebackdrop cache: Yes];
else
[uiview setanimationtransition: uiviewanimationtransitionflipfromright forview: whitebackdrop cache: Yes];

Nsinteger Purple = [[whitebackdrop subviews] indexofobject: [whitebackdrop viewwithtag:999];
Nsinteger maroon = [[whitebackdrop subviews] indexofobject: [whitebackdrop viewwithtag:998];
[Whitebackdrop exchangesubviewatindex: Purple withsubviewatindex: maroon];

[Uiview setanimationdelegate: Self];
[Uiview setanimationdidstopselector: @ selector (animationfinished :)];
[Uiview commitanimations];
}

 

 

 

 

 

 

 

 

 

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.