码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-11-30 23:05:24      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:新浪微博   color   height   int   load   bundle   nil   view   nsbundle   

 

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

最终效果:

技术分享

 

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

标签:新浪微博   color   height   int   load   bundle   nil   view   nsbundle   

原文地址:http://www.cnblogs.com/yongdaimi/p/6119756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!