123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // DRBottomShareView.m
- // YouHuiProject
- //
- // Created by 小花 on 2019/1/2.
- // Copyright © 2019年 kuxuan. All rights reserved.
- //
- #import "DRBottomShareView.h"
- #import <WXApi.h>
- @implementation DRBottomShareView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- NSArray *titles = @[@"分享朋友圈",@"分享给好友",@"复制淘口令",@"批量存图"];
- NSArray *icons = @[@"wx_section",@"wx_wechat",@"copy_code",@"save_img"];
- CGFloat width = (self.width)/4;
- CGFloat height = width;
- for (int i = 0; i < titles.count; i++) {
- UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i*width, 0, width, height)];
- [button setTitle:titles[i] forState:UIControlStateNormal];
- button.titleLabel.font = [UIFont systemFontOfSize:13];
- [button setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
- [button setImage:[UIImage imageNamed:icons[i]] forState:UIControlStateNormal];
- [button setButtonImageTitleStyle:ButtonImageTitleStyleTop padding:10];
- button.tag = 1000+i;
- [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:button];
- if (i<2 && ![WXApi isWXAppInstalled]) {
- button.hidden = YES;
- }
- }
- }
- - (void)buttonAction:(UIButton *)sender {
- NSInteger index = sender.tag - 1000;
- if (self.delegate && [self.delegate respondsToSelector:@selector(BottomShareViewDidSelectedIndex:)]) {
- [self.delegate BottomShareViewDidSelectedIndex:index];
- }
- }
- @end
|