First we track Uistatusbar touch events and need to add the following code to the Appdelegate
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event { [Super touchesbegan:touches withevent:event]; Cgpoint location = [[[Event Alltouches] anyobject] LocationInView:self.window]; CGRect statusbarframe = [UIApplication sharedapplication].statusbarframe; if (Cgrectcontainspoint (Statusbarframe)) {[Self statusbartouchedaction];} }
Then in the Statusbartouchedaction method, the ScrollView that appears in the current Keywindow scroll to the top
-(void) Statusbartouchedaction {
[[Ddtopwindow Defaultddtopwindow] scrollstotop];
}
Here's a look at Jmsuiscrollviewtool
@interface Ddtopwindow:uiview
+ (instancetype) Defaultddtopwindow;
-(void) Configscrollview: (Uiscrollview *) ScrollView iscantop: (BOOL) iscantop;
-(void) scrollstotop;
@end
#import "DDTopWindow.h"
Static Uiscrollview *scrollview_;
@interface Ddtopwindow ()
@property (nonatomic, assign) BOOL IsCan;
@end
@implementation Ddtopwindow
Synthesize_singleton_for_class_arc (Ddtopwindow);
-(void) Configscrollview: (Uiscrollview *) ScrollView iscantop: (BOOL) Iscantop {
Scrollview_ = ScrollView;
Self.iscan = Iscantop;
}
-(void) Scrollstotop {
if (scrollview_.scrollenabled) {
[Scrollview_ Setcontentoffset:cgpointmake (Scrollview_.contentoffset.x,-scrollview_.contentinset.top) animated: YES];
}
}
@end
iOS development get the status bar click events