iOS小项目iOS开发部落iOS实用

可拖拽的小窗口,最好用?

2016-12-23  本文已影响833人  gitKong

一、前言

截图来自某牙直播

二、功能分析(针对所有控件)

支持xib、storyboard 参数设置

三、API 分析设计

/**
 *  @author gitKong
 *
 *  是否允许拖拽,默认关闭(可以在XIB或SB中设置)
 */
@property (nonatomic,assign)IBInspectable BOOL fl_canDrag;
/**
 *  @author gitKong
 *
 *  是否需要边界弹簧效果,默认开启(可以在XIB或SB中设置)
 */
@property (nonatomic,assign)IBInspectable BOOL fl_bounces;
/**
 *  @author gitKong
 *
 *  是否需要吸附边界效果,默认开启(可以在XIB或SB中设置)
 */
@property (nonatomic,assign)IBInspectable BOOL fl_isAdsorb;

四、功能实现分析

if (gesR.view.fl_centerX + self.superview.fl_x > self.superview.fl_centerX) {
    [UIView animateWithDuration:0.25 animations:^{
        gesR.view.center = CGPointMake(self.superview.fl_width - self.fl_width / 2, y);
    }];
    
}
else{
    [UIView animateWithDuration:0.25 animations:^{
        gesR.view.center = CGPointMake(self.fl_width / 2, y);
    }];
}
计算小坑

五、注意点:

使用约束布局可能会出现这种情况

六、总结

上一篇 下一篇

猜你喜欢

热点阅读