|
//
// sinaAndWeChatCell.m
// ThePaperDemo
//
// Created by scar1900 on 14-9-22.
// Copyright (c) 2014年 scar1900. All rights reserved.
//
#import "sinaAndWeChatCell.h"
#import "blueButton.h"
#import "shareUtil.h"
@interface sinaAndWeChatCell() {
CGFloat contentPadding;
}
@property(nonatomic, strong)blueButton *sinaBtn;
@property(nonatomic, strong)blueButton *weChatHaoyou;
@property(nonatomic, strong)blueButton *weChatPengyouquan;
@end
@implementation sinaAndWeChatCell
@synthesize contentBO;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
if (IS_IPHONE_6P) {
contentPadding = 15;
}else if (IS_IPHONE_6) {
contentPadding = 15;
}else {
contentPadding = 10;
}
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.sinaBtn];
[self.contentView addSubview:self.weChatHaoyou];
[self.contentView addSubview:self.weChatPengyouquan];
[self setlayoutSubviews];
}
return self;
}
- (blueButton*)sinaBtn {
if (!_sinaBtn) {
_sinaBtn = [[blueButton alloc]initWithFrame:CGRectZero withColor:nil];
[_sinaBtn setImageInShare:Image(@"detailPage/sina.png")];
_sinaBtn.textLabel.text = @"新浪微博";
[_sinaBtn addTarget:self action:@selector(sinaEvent:) forControlEvents:UIControlEventTouchUpInside];
}
return _sinaBtn;
}
- (blueButton*)weChatHaoyou {
if (!_weChatHaoyou) {
_weChatHaoyou = [[blueButton alloc]initWithFrame:CGRectZero withColor:nil];
[_weChatHaoyou setImageInShare:Image(@"detailPage/weChatHaoyou.png")];
_weChatHaoyou.textLabel.text = @"微信好友";
[_weChatHaoyou addTarget:self action:@selector(haoyouEvent:) forControlEvents:UIControlEventTouchUpInside];
}
if (![shareUtil isHaveWeChatClient]) {
_weChatHaoyou.enabled = NO;
}else _weChatHaoyou.enabled = YES;
return _weChatHaoyou;
}
- (blueButton*)weChatPengyouquan {
if (!_weChatPengyouquan) {
_weChatPengyouquan = [[blueButton alloc]initWithFrame:CGRectZero withColor:nil];
[_weChatPengyouquan setImageInShare:Image(@"detailPage/weChatPengyouquan.png")];
_weChatPengyouquan.textLabel.text = @"微信朋友圈";
[_weChatPengyouquan addTarget:self action:@selector(pengyouquanEvent:) forControlEvents:UIControlEventTouchUpInside];
}
if (![shareUtil isHaveWeChatClient]) {
_weChatPengyouquan.enabled = NO;
}else _weChatPengyouquan.enabled = YES;
return _weChatPengyouquan;
}
- (void)sinaEvent:(UIButton*)btn {
[shareUtil shareNews:self.contentBO.shareUrl
imageUrl:self.contentBO.sharePic
title:self.contentBO.name
summary:nil
shareType:sinaWeiBoShareType
shareStyle:shareNewsStyle
completion:nil];
}
//微信好友分享
- (void)haoyouEvent:(UIButton*)btn {
[shareUtil shareNews:self.contentBO.shareUrl
imageUrl:self.contentBO.sharePic
title:self.contentBO.name
summary:nil
shareType:weChatSessionShareType
shareStyle:shareNewsStyle
completion:nil];
}
//微信朋友圈分享
- (void)pengyouquanEvent:(UIButton*)btn {
[shareUtil shareNews:self.contentBO.shareUrl
imageUrl:self.contentBO.sharePic
title:self.contentBO.name
summary:nil
shareType:weChatTimeLineShareType
shareStyle:shareNewsStyle
completion:nil];
}
- (void)setlayoutSubviews {
CGFloat btnWidth = (rect_screen.size.width-2*contentPadding-10)/3;
// self.sinaBtn.frame = CGRectMake(10, 10, 194/2, 30);
[self.sinaBtn makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(contentPadding);
make.top.equalTo(self.contentView).offset(10);
make.height.equalTo(@30);
make.width.equalTo(@(btnWidth));
}];
// self.weChatHaoyou.frame = CGRectMake(10+194/2+9/2, 10, 194/2, 30);
[self.weChatHaoyou makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.sinaBtn.right).offset(5);
make.top.equalTo(self.contentView).offset(10);
make.height.equalTo(@30);
make.width.equalTo(@(btnWidth));
}];
// self.weChatPengyouquan.frame = CGRectMake(10+194+9, 10, 194/2, 30);
[self.weChatPengyouquan makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.weChatHaoyou.right).offset(5);
make.top.equalTo(self.contentView).offset(10);
make.height.equalTo(@30);
make.width.equalTo(@(btnWidth));
}];
}
@end
|