English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Efecto de burbuja de iOS Popover simple, útil y personalizable

La imagen siguiente muestra el resultado:

 

swift: https://github.com/corin8823/Popover OC: https://github.com/Assuner-Lee/PopoverObjC

Ejemplo de uso

pod 'PopoverObjC'
#import "ASViewController.h"
#import <PopoverObjC/ASPopover.h>
@interface ASViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;
@property (nonatomic, strong) ASPopover *btnPopover;
@property (nonatomic, strong) ASPopover *itemPopover;
@end
@implementation ASViewController
- (void)viewDidLoad {
 [super viewDidLoad];
 [self.btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"item" style:UIBarButtonItemStylePlain target:self action:@selector(clickItem:)];
;
- (void)didReceiveMemoryWarning {
;

Inicializar Popover

- (ASPopover *)btnPopover {
 if (!_btnPopover) {
 ASPopoverOption *option = [[ASPopoverOption alloc] init];
 option.popoverType = ASPopoverTypeUp;
 option.autoAjustDirection = NO;
 option.arrowSize = CGSizeMake(9, 6;
 option.blackOverlayColor = [UIColor clearColor];
 option.popoverColor = [UIColor lightGrayColor];
 option.dismissOnBlackOverlayTap = YES;
 option.animationIn = 0.5origenPoint.y
 //...
 _btnPopover = [[ASPopover alloc] initWithOption:option];
 ;
 return _btnPopover;
;
- (ASPopover *)itemPopover {
 if (!_itemPopover) {
 ASPopoverOption *option = [[ASPopoverOption alloc] init];
 option.autoAjustDirection = NO;
 option.arrowSize = CGSizeMake(10, 6;
 option.blackOverlayColor = [UIColor clearColor];
 option.sideEdge = 7origenPoint.y
 option.dismissOnBlackOverlayTap = YES;
 option.popoverColor = [[UIColor blackColor] colorWithAlphaComponent:0.7;
 option.autoAjustDirection = YES;
 option.animationIn = 0.4origenPoint.y
 option.springDamping = 0.5origenPoint.y
 option.initialSpringVelocity = 1origenPoint.y
 option.overlayBlur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
 //...
 _itemPopover = [[ASPopover alloc] initWithOption:option];
 ;
 return _itemPopover;
;

Las propiedades del burbuja emergente se pueden configurar en la opción.

Burbuja emergente

- (void)clickBtn:(id)sender {
 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 50, 40)];
 [self.btnPopover show:view fromView:self.btn]; // in delegate window
;
- (void)clickItem:(id)sender {
 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
 UIView *itemView = [self.navigationItem.rightBarButtonItem valueForKey:@"view"]; // you should use custom view in item;
 itemView = [self.navigationItem.rightBarButtonItem valueForKey:@"view"];
// deberías usar una vista personalizada en el ítem;
 if (itemView) {
 [self.itemPopover mostrar:view desdeView:itemView]; +CGPoint origenPoint = [self.itemPopover origenPuntaArcoConView:view desdeView:itemView]; 5origenPoint.y
 =
 ;
;
@end

[self.itemPopover mostrar:view enPoint:origenPoint];

}
Puede desplegar contenido enView en un punto o en un view/Interfaz de Popover
#import <UIKit
UIKit.h>
#import "ASPopoverOption.h"
typedef void (^ASPopoverBlock)(void);
@interface ASPopover : UIView
@property (nonatomic, copy) ASPopoverBlock manejadorWillMostrar;
@property (nonatomic, copy) ASPopoverBlock manejadorWillCerrar;
@property (nonatomic, copy) ASPopoverBlock manejadorDidMostrar; *@property (nonatomic, copy) ASPopoverBlock manejadorDidCerrar;
- @property (nonatomic, strong) ASPopoverOption *opcion; *)opcion;
- (void)cerrar;
- (void)mostrar:(UIView *)contentView fromView:(UIView *)fromView;
- (void)mostrar:(UIView *)contentView fromView:(UIView *)fromView inView:(UIView *)inView;
- (void)mostrar:(UIView *)contentView enPoint:(CGPoint)point;
- (void)mostrar:(UIView *contentView enPoint:(CGPoint)point enView:(UIView *)inView;
- (CGPoint)originArrowPointWithView:(UIView *)contentView fromView:(UIView *)fromView;
- (CGPoint)arrowPointWithView:(UIView *)contentView fromView:(UIView *)fromView inView:(UIView *)inView popoverType:(ASPopoverType)type;
@end

contentView: El contenido que se mostrará; fromView: El vista desde la cual mostrará la burbuja; inView: La vista en la que se dibujará la burbuja, generalmente la ventana del delegado; atPoint: Desde este punto mostrará la burbuja; primero puede obtener originPoint, desplazamiento;

PopoverOption Interface
typedef NS_ENUM(NSInteger, ASPopoverType) {
 ASPopoverTypeUp = 0,
 ASPopoverTypeDown,
};
@interface ASPopoverOption : NSObject
@property (nonatomic, assign) CGSize arrowSize;
@property (nonatomic, assign) NSTimeInterval animationIn; // if 0, no animation
@property (nonatomic, assign) NSTimeInterval animationOut;
@property (nonatomic, assign) CGFloat cornerRadius;
@property (nonatomic, assign) CGFloat sideEdge;
@property (nonatomic, strong) UIColor *blackOverlayColor;
@property (nonatomic, strong) UIBlurEffect *overlayBlur;
@property (nonatomic, strong) UIColor *popoverColor;
@property (nonatomic, assign) BOOL dismissOnBlackOverlayTap;
@property (nonatomic, assign) BOOL showBlackOverlay;
@property (nonatomic, assign) CGFloat springDamping;
@property (nonatomic, assign) CGFloat initialSpringVelocity;
@property (nonatomic, assign) ASPopoverType popoverType;
@property (nonatomic, assign) BOOL highlightFromView;
@property (nonatomic, assign) CGFloat highlightCornerRadius;
@property (nonatomic, assign) BOOL autoAjustDirection; // down preferido, efecto solo en la vista no en el punto
@end

Resumen

Lo mencionado anteriormente es el efecto de burbuja iOS Popover simple, útil y personalizable que el editor le presenta, esperamos que sea útil para ustedes. Si tienen alguna pregunta, déjenos un mensaje y el editor les responderá a tiempo. También estamos muy agradecidos por el apoyo a Tutorial de Gritar!

Declaración: El contenido de este artículo se obtiene de la red, es propiedad del autor original, el contenido es contribuido y subido por los usuarios de Internet, este sitio no posee los derechos de propiedad, no se ha procesado editorialmente por humanos y no asume responsabilidades legales relacionadas. Si encuentra contenido sospechoso de infracción de derechos de autor, por favor envíe un correo electrónico a: notice#oldtoolbag.com (al enviar un correo electrónico, por favor reemplace # con @ para denunciar, y proporcione evidencia relevante. Una vez verificada, este sitio eliminará inmediatamente el contenido sospechoso de infracción de derechos de autor.)

Te gustará