Use of 1.UISegmentedControl
Split controller is the basic use of several switches connected together
Uisegmentedcontrol *SEGMENTEDVC = [[Uisegmentedcontrol alloc] initwithitems:@[@ "spatial dynamics", @ "JIII", @ "DDA"];
Sets the background color it selects
Segmentedvc.tintcolor = [Uicolor Graycolor];
Which one is selected by default
Segmentedvc.selectedsegmentindex = 0;
Segmentedvc.frame = CGRectMake (0, 0, 320, 35);
Self.navigationItem.titleView = SEGMENTEDVC;
SELF.SEGMENTEDVC = SEGMENTEDVC;
2.switch Precautions for use
Switch (ButtonType) {
Case://Mood 0
{
If you want to define a variable in switch, be sure to add braces, let it clear the scope, from that place to where
To write multiple lines of code, you must add a brace here, because the scope of the problem
Break
}
3. Add a left and right drag effect to a view code
Add a drag gesture to Contentview
Uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (pan:)];
[Contenview Addgesturerecognizer:pan];
}
/**
* But this method is called when the Contentview is dragged
*/
-(void) pan: (Uipangesturerecognizer *) pan
{
Remove View drag move distance
Cgpoint point = [Pan TranslationInView:pan.view];
if (pan.state = = Uigesturerecognizerstateended | | pan.state = = uigesturerecognizerstatecancelled) {//When dragging ends or drags is interrupted, view restores The original position
Revert to the original location
Self.contenView.transform = cgaffinetransformidentity;
} else {
Point.x * 0.2 produces a good drag effect, with a good user experience
Self.contenView.transform = cgaffinetransformmaketranslation (point.x * 0.2, 0);
}
}
The use of some statements in iOS development