• 新浪微博客户端(46)-点击表情按钮弹出表情


    DJEmotionPageView.m

    /**
     * 点击表情监听方法
     * param btn 点击的表情按钮
     */
    - (void)emotionBtnClick:(DJEmotionButton *)btn {
    
        // 获取当前应用程序最顶层的窗口
        UIWindow *lastWindow = [[UIApplication sharedApplication].windows lastObject];
        
        // 转换btn当前坐标系
        CGRect newFrame = [btn convertRect:btn.bounds toView:nil];
        
        self.popView.centerX = CGRectGetMidX(newFrame);
        self.popView.y = CGRectGetMaxY(newFrame) - self.popView.height;
        
        // 将当前点击按钮的表情模型传递给popview
        self.popView.emotion = btn.emotion;
        
        [lastWindow addSubview:self.popView];
    
    }

    DJEmotionPopView.m

    #import "DJEmotionPopView.h"
    #import "DJEmotionButton.h"
    
    
    @interface DJEmotionPopView()
    
    // 表情
    @property (weak, nonatomic) IBOutlet DJEmotionButton *emotionView;
    
    @end
    
    
    @implementation DJEmotionPopView
    
    + (instancetype)popView {
    
        return [[[NSBundle mainBundle] loadNibNamed:@"DJEmotionPopView" owner:nil options:nil] lastObject];
    }
    
    
    - (void)setEmotion:(DJEmotion *)emotion {
        _emotion = emotion;
        self.emotionView.emotion = emotion;
    }
    
    
    #pragma mark - 当从Xib中加载View的时候不会调用initWithFrame方法,则是直接调用initWithCoder及awakeFromNib方法
    
    
    - (instancetype)initWithCoder:(NSCoder *)decoder
    {
        self = [super initWithCoder:decoder];
        if (self) {
         
            self.emotionView.titleLabel.font = [UIFont systemFontOfSize:32];
            
        }
        return self;
    }
    
    
    - (void)awakeFromNib {
    
    
    }
    
    
    
    @end

    最终效果:

  • 相关阅读:
    [数据结构] N皇后问题
    [2011山东ACM省赛] Sequence (动态规划)
    yaf 学习
    nginx 配置文件
    nginx.conf 理解
    fastcgi
    Nginx+FastCGI运行原理
    ssh-key 原理
    Git是个啥 ssh是个啥
    Git SSH Key 生成步骤
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/6119756.html
Copyright © 2020-2023  润新知