The original link
In the process of App project development, there are always various needs for pop-ups, such as the top popover, the top popover, the middle popover and so on. The development of popovers generally includes pop-up animation, exit animation, translucent mask, UI and logic of popovers themselves, etc. If each popover has to go through this process, it will be inefficient and boring. So is there a solution where we can just code the UI and logic of the popover itself? That’s why I open source YsyPopHelper, an easy-to-use iOS popover developer.
Demo address: github.com/ysyplay/Ysy…
Functions and Uses
1. Customizable pop-ups, disappearing animations and directions. 2. You can customize the pop-up position. 3. Automatically avoid the keyboard to prevent being blocked by the keyboard. 4. You can specify the parent view of the subrack. 5. Just focus on the UI and business logic of the popover itself. IOS development exchange technology group: 563513413, no matter you are big bull or small white are welcome to enter, share BAT, Ali interview questions, interview experience, discuss technology, we exchange learning and growth together!
#import <UIKit/UIKit.h> #import "YsyPopMacro.h" NS_ASSUME_NONNULL_BEGIN @interface YsyPopHelper : UIView /** * Initialization method * @param customView custom popup * @param popStyle display style * @Param position pop up position */ - (instancetype)initWithCustomView:(UIView *_Nonnull)customView popStyle:(YsyPopStyle)popStyle dismissStyle:(YsyDismissStyle)dismissStyle position:(YsyPosition)position; // display popup - (void)show; /// Vanish popover - (void)dismiss; @property (nonatomic, assign) NSTimeInterval popDuration; /// dismiss animation time @property (nonatomic, assign) NSTimeInterval; dismissDuration; ///x offset @property (nonatomic, assign) CGFloat offsetX; ///y offset @property (nonatomic, assign) CGFloat offsetY; /// set the parent view to window.property (nonatomic, weak) UIView *superView; /// Whether to avoid keyboard default YES @Property (nonatomic, assign) BOOL isAvoidKeyboard; /// The distance between popbox and keyboard defaults to 10 @Property (Nonatomic, assign) CGFloat avoidKeyboardSpace; @property (nonatomic, assign) BOOL disableTapBg; @end NS_ASSUME_NONNULL_ENDCopy the code
Method of use
TestView *popView = [TestView new]; Popview. bounds = CGRectMake(0, 0, 260,291); / / initialize the pop-up assistant _helper = [[YsyPopHelper alloc] initWithCustomView: popView popStyle: YsyPopStyleFade dismissStyle:YsyDismissStyleScale position:YsyPositonCenter]; // Popover helper calls the presentation method [_helper show];Copy the code
You can see 3 lines of code, you can use the popover, easy and quick, low redundancy. For more customized requirements, see Demo. If you think it works, please light up the little star 🌟.