First, notice
1. Monitoring Notifications
-(void) Addobserver: (ID) Observer selector: (SEL) aselector name: (NSString *) AName object: ( ID) anobject;
The aselector method of observer is called when the AnObject object publishes a notification named AName
2. Release Notifications
Publish a Notification object (name,object,userInfo)
-(void) Postnotification: (nsnotification *) notification;
AnObject released a notice named AName .
-(void) Postnotificationname: (NSString *) AName object: (ID) anobject;
AnObject released a notification named AName , and passed an extra data:auserinfo
-(void) Postnotificationname: (NSString *) AName object: (ID) anobject userInfo: (Nsdictionary *) Auserinfo;
Second, load the controller from the storyboard inside
1. load Storyboard
1> method 1: Use the name of the storyboard file
+ (Uistoryboard *) Storyboardwithname: (NSString *) name Bundle: (NSBundle *) Storyboardbundleornil;
2> method 2: Storyboard Method of the controller
-[Uiviewcontroller Storyboard]
2. Loading the Controller
returns the first controller (initialization controller, the controller that the Arrow refers to)
-(ID) instantiateinitialviewcontroller;
returns a controller that uniquely identifies the identifier
-(ID) Instantiateviewcontrollerwithidentifier: (NSString *) identifier;
Third,block definition Format
1. definition of block variables
void (^myblock) (int, int);
Myblock = ^ (int A, int b) {
};
int age = ten;
2. definition of @property
@property (nonatomic, copy) void (^myblock) (int, int);
@property (nonatomic, assign) int age ;
3. parameters as methods
-(void) Setmyblock: (void (^) (int, int)) Myblock;
-(void) Setage: (int) age;
Iv. Common functions of CGRect
1. functions such as Cgrectgetminx (cgrect rect)
2.Cgrectcontainspoint (< #CGRect Rect#>, < #CGPoint point#>)
Five, the cutting of UIImage
Cgimagecreatewithimageinrect (< #CGImageRef Image#>, < #CGRect rect#>)
VI, anti-aliasing
-(void) Clearalias
{
self. layer.borderwidth = 2;
self. layer.bordercolor = [Uicolor Clearcolor]. Cgcolor;
// the layer will be rendered as a bitmap
self. layer.shouldrasterize = YES;
for (UIView *child in self . subviews) {
[Child Clearalias];
}
}
Seven, timer
1.Nstimer
1> Human control refresh rate
2> low Refresh speed requirements, suitable for slow refresh
3> Create a timer
returns a new timer, but does not start the timer and needs to call The Fire method
+ (Nstimer *) Timerwithtimeinterval: (nstimeinterval) ti target: (ID) atarget selector: (SEL) Aselector UserInfo: (ID) UserInfo repeats: (BOOL) yesorno;
return a new timer and start the timer immediately
+ (Nstimer *) Scheduledtimerwithtimeinterval: (nstimeinterval) ti target: (ID) atarget selector: (SEL) Aselector UserInfo: (ID) UserInfo repeats: (BOOL) yesorno;
4> Stop Timer ( as long as the timer stops, you cannot start the timer again )
-(void) invalidate;
2.Cadisplaylink
1> includes quartzcore frame
2> fixed Refresh frequency (1 seconds refreshed )
3> high demand for refresh speed, suitable for fast refresh
4> create displaylink
returns an cadisplaylink timer object that calls The Sel method of target in 1 seconds and Cadisplaylink as a parameter passed in
+ (Cadisplaylink *) Displaylinkwithtarget: (ID) Target selector: (sel) sel;
5> start timing
-(void) Addtorunloop: (Nsrunloop *) Runloop Formode: (NSString *) mode;
6> Stop timing
-(void) invalidate;
7> Brush frame interval
@property(readonly, nonatomic) cftimeinterval duration;
8> control Pause or Continue
@property(getter=ispaused, nonatomic) BOOL paused;
Eight, animation
1.UIView encapsulated animations
1> End -to- end
[UIView beginanimations:nil context:nil];
// ... What animations need to be performed
[UIView commitanimations];
2> Block
[UIView animatewithduration:0.5 animations:^{
// animations that need to be performed
} completion:^ (BOOL finished) {
// animation complete
}];
3> Transitions Animation ( transition animation )
make a view perform a transition animation
[UIView transitionwithview:<# (UIView *) #> duration:<# (nstimeinterval) #> options:<# ( uiviewanimationoptions) #> animations:<#^ (void) animations#> completion:<#^ (BOOL finished) completion# >];
2.Calayer 's animation
What values can the keypath of cabasicanimation and cakeyframeanimation be?
Search in Xcode documents:calayer animatable Properties
specific properties of transform: Search catransform3d key path
1> Cabasicanimation
* Fromvalue Initial value
* Tovalue Final value (from initialization change to last value)
* Byvalue Step value (based on initial value, how many values are added)
2> Cakeyframeanimation
* Values
3> catransition ( transition animation )
Catransition *anim = [catransition animation];
Anim.type = @ "cube";
Anim.subtype = Kcatransitionfrombottom;
[View.layer addanimation:anim Forkey:nil];
4> Caanimationgroup
* animation, you can perform multiple animations at the same time
3. How to select an animation
1> If you need to perform multiple animations repeatedly, it's best to choose calayer animations
2> If the animation is finished, it is necessary to use some of the previous things, the best choice of UIView block animation
3> If you need to perform multiple animations simultaneously, it's best to choose caanimationgroup
4> UIView animation and Calayer animation is the most flexible calayer Animation
4. Customize some animations
Use Cadisplaylink tocomplete animations that need to be performed in the brush frame method
iOS Basics Summary (i)