ios - How to improve the performance of UINavigationController's snapshot -
i use block of code take snapshot of uinavigationcontroller's view:
@implementation uiview (snapshot) - (uiimage*)snapshot { nstimeinterval t0 = [[nsprocessinfo processinfo] systemuptime]; uigraphicsbeginimagecontextwithoptions(self.frame.size, self.opaque, [[uiscreen mainscreen] scale]); if([self iskindofclass:[uiscrollview class]]){ cgcontextref ctx = uigraphicsgetcurrentcontext(); cgcontexttranslatectm(ctx, 0, -((uiscrollview*)self).contentoffset.y); } [self.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *snapshotimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); nstimeinterval t1 = [[nsprocessinfo processinfo] systemuptime]; nslog(@"time cost: %lf", t1 - t0); return snapshotimage; } @end
1,
jasidepanelcontroller *sidepanelcontroller = //... uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:sidepanelcontroller]; [navcontroller.view snapshot]; // **cost 1 seconds**
2,
jasidepanelcontroller *sidepanelcontroller = //... uinavigationcontroller *navcontroller = //...; sidepanelcontroller.centerpanel = navcontroller; [navcontroller.view snapshot]; // **cost 0.1 seconds**
any methods improve performance?
i found reason: because jasidecontroller add uibezierpath view.layer in (void)stylecontainer:(uiview *)container animate:(bool)animate duration:(nstimeinterval)duration
Comments
Post a Comment