Full Screen swipe

Source: Internet
Author: User

#import "LZJNavigationViewController.h"

#import <objc/runtime.h>

@interface LZJnavigationviewcontroller () <uinavigationcontrollerdelegate, Uigesturerecognizerdelegate>

/** System gesture Agent * /

@property (nonatomic, strong) ID popgesture;

@end

@implementation Lzjnavigationviewcontroller

When the call is called when the program starts

function : load the current class into memory and place it in the code area

+ (void) load{

NSLog (@ "%s", __func__);

//}

When to call when the first time the class is initialized

function initialization of this class

+ (void) initialize{

NSLog (@ "%s", __func__);

//1. get the navigation bar identification

// get the APP's navigation bar identification

//Appearance is an agreement that has this approach as long as it complies with this agreement

// If there is a significant bug in this writing

Uinavigationbar *bar = [Uinavigationbar appearance];

//Class gets the navigation bar identification for some classes

uinavigationbar *bar = [uinavigationbar appearancewhencontainedin:self,nil ];

//Button

[UIButton appearance];

[UILabel appearance];

//

[Bar setbackgroundimage: [UIImage imagenamed:@ "NavBar64"] forbarmetrics: Uibarmetricsdefault];

// Set font color size

nsmutabledictionary *DICTM = [nsmutabledictionary dictionary];

// font size

dictm[nsfontattributename] = [uifont boldsystemfontofsize:];

// font Color

dictm[nsforegroundcolorattributename] = [uicolor whitecolor];

[Bar settitletextattributes:d ICTM];

// set The foreground color of the navigation bar

[Bar settintcolor: [uicolor whitecolor];

Bar

// Gets the identification of the navigation bar button

uibarbuttonitem *item = [uibarbuttonitem appearancewhencontainedin:self, nil ];

// Modify the position of the return button title

[Item setbackbuttontitlepositionadjustment:uioffsetmake(0,-) Forbarmetrics:uibarmetricsdefault];

}

-(void) viewdidload {

[Super viewdidload];

// Full Screen slide Remove controller

/*

<UIScreenEdgePanGestureRecognizer:0x7ff934361e20; state = Possible; Delaystouchesbegan = YES; View = <uilayoutcontainerview 0x7ff93257ace0>; target= < (action=handlenavigationtransition:, Target=<_uinavigationinteractivetransition 0x7ff934361390> ) >>

(LLDB)

*/

//1. Modify the system's gestures first , the system does not provide us with properties

NSLog (@ "%@", Self.interactivepopgesturerecognizer);

uiscreenedgepangesturerecognizer *gest = self. Interactivepopgesturerecognizer;

2. add your own gestures

Uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector ( Handlenavigationtransition:)];

[Self.view Addgesturerecognizer:pan];

// missing Target system's private properties

//KVC [Gest valueforkeypath:@ "];

// do not know the real type of Target

The //OC Runtime mechanism can only dynamically get the member properties of the current class , cannot get its subclasses , or the properties of the parent class

///__unsafe_unretained class to get the member property of

//unsigned int *outcount gets The number of all member properties under Class

unsigned int outcount = 0;

//

Ivar *ivars = Class_copyivarlist ([Uigesturerecognizer class], &outcount);

for (int i = 0; i<outcount; i++) {

Ivars[i];

gets the name of the member property

NSString *name = @ (Ivar_getname (ivars[i]));

NSLog (@ "%@", name);

//

//    }

//(action=handlenavigationtransition:, Target=<_uinavigationinteractivetransition 0x7fd9db250ce0>)

//_targets

Nsarray *targets = [Gest valueforkeypath:@ "_targets"];

NSLog (@ "%@", Targets[0]);

//

//

ID target = [targets[0] valueforkeypath:@ "_target"];

Uipangesturerecognizer *pan1 = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (PAN)];

[Self.view Addgesturerecognizer:pan1];

Pan1.delegate = self;

//

ID target = self. Interactivepopgesturerecognizer. Delegate;

//

2. add your own gestures

disable gestures from the system

self. Interactivepopgesturerecognizer. Enabled = NO;

uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget: Target action:@selector(handlenavigationtransition:)];

pan.enabled = NO;

[self. View Addgesturerecognizer:p an];

Pan. delegate = self;

}

#pragma mark-uigesturerecognizerdelegate

when it starts to slide, it will be called. If you return YES, you can swipe back to No, disable gestures

-(BOOL) Gesturerecognizershouldbegin: (uigesturerecognizer *) gesturerecognizer{

// when the controller is not removed ( Forbidden ), the charge root controller allows removal of the control

NSLog (@ "%ld", Self.viewControllers.count);

BOOL open = self. Viewcontrollers. Count > 1;

return open;

}

-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{

[Super Pushviewcontroller:viewcontroller animated:animated];

//}

-(void) back{

[self popviewcontrolleranimated:YES];

}

@end

Full Screen swipe

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.