| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- //
- // YBLivePreview.m
- // YBVideo
- //
- // Created by YB007 on 2019/11/29.
- // Copyright © 2019 cat. All rights reserved.
- //
- #import "YBLivePreview.h"
- #import "ZFModalTransitionAnimator.h"
- #import "startLiveClassVC.h"
- #import "YBShareView.h"
- @interface YBLivePreview()<UITextViewDelegate,TZImagePickerControllerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
- UIImageView *loactionImgView;
- UILabel *locationLabel;
-
- UIButton *preThumbBtn; //上传封面按钮
- UILabel *thumbLabel; //上传封面状态的label
-
- UITextView *liveTitleTextView;
- UILabel *textPlaceholdLabel;
- NSMutableArray *preShareBtnArray; //分享按钮数组
- NSString *selectShareName; //选择分享的名称
-
- UILabel *liveClassLabel;
- NSString *liveClassID;
- NSArray *_funcTypeArr;
- UIButton *openGoodsCar;
- }
- @property (nonatomic, strong) ZFModalTransitionAnimator *animator;
- @end
- @implementation YBLivePreview
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- liveClassID = @"-99999999";
- [self createUI];
- }
- return self;
- }
- -(void)createUI {
- _inputTitleStr = @"";
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hidePreTextView)];
- [self addGestureRecognizer:tap];
-
- loactionImgView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 42+statusbarHeight, 22, 22)];
- loactionImgView.image = [UIImage imageNamed:@"pre_location"];
- [self addSubview:loactionImgView];
- UIView *locationLabelView = [[UIView alloc]init];
- locationLabelView.backgroundColor = RGB_COLOR(@"#000000", 0.3);
- locationLabelView.layer.cornerRadius = 8;
- locationLabelView.layer.masksToBounds = YES;
- [self addSubview:locationLabelView];
- [locationLabelView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(loactionImgView);
- make.left.equalTo(loactionImgView.mas_right).offset(-8);
- make.height.mas_equalTo(22);
- }];
-
- locationLabel = [[UILabel alloc]init];
- locationLabel.font = [UIFont systemFontOfSize:11];
- locationLabel.textColor = [UIColor whiteColor];
- locationLabel.text = [cityDefault getLocationCity];
- [locationLabelView addSubview:locationLabel];
- [locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(locationLabelView);
- make.height.mas_equalTo(22);
- make.left.equalTo(locationLabelView).offset(10);
- make.right.equalTo(locationLabelView).offset(-10);
- }];
- [self insertSubview:locationLabelView belowSubview:loactionImgView];
- UIButton *locationSwitchBtn = [UIButton buttonWithType:0];
- [locationSwitchBtn addTarget:self action:@selector(locationSwitchBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:locationSwitchBtn];
- [locationSwitchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.height.equalTo(loactionImgView);
- make.right.equalTo(locationLabelView);
- }];
- //定位不展示做隐藏处理
- loactionImgView.hidden = locationLabelView.hidden = locationSwitchBtn.hidden = YES;
-
- // UIButton *switchBtn = [UIButton buttonWithType:0];
- // [switchBtn setImage:[UIImage imageNamed:@"pre_camer"] forState:0];
- // [switchBtn addTarget:self action:@selector(rotateCamera) forControlEvents:UIControlEventTouchUpInside];
- // [self addSubview:switchBtn];
- // [switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // //make.left.equalTo(locationLabelView.mas_right).offset(10);
- // make.left.equalTo(self.mas_left).offset(10);
- // make.centerY.equalTo(locationSwitchBtn);
- // make.height.width.equalTo(loactionImgView.mas_height);
- // }];
- _locationSwitch = YES;
-
-
- UIButton *preCloseBtn = [UIButton buttonWithType:0];
- preCloseBtn.frame = CGRectMake(16, loactionImgView.top, loactionImgView.height, loactionImgView.height);
- [preCloseBtn setImage:[UIImage imageNamed:@"pub_back"] forState:0];
- [preCloseBtn addTarget:self action:@selector(doClosePreView) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:preCloseBtn];
- //
-
- // UIView *preMiddleView = [[UIView alloc]initWithFrame:CGRectMake(10, _window_height/2-(_window_width-20)*38/71, _window_width-20, (_window_width-20)*38/71)];
- UIView *preMiddleView = [[UIView alloc]initWithFrame:CGRectMake(10, _window_height/3-(_window_width-20)*0.31, _window_width-20, (_window_width-20)*0.31)];
- preMiddleView.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
- preMiddleView.layer.cornerRadius = 5;
- [self addSubview:preMiddleView];
-
- preThumbBtn = [UIButton buttonWithType:0];
- // preThumbBtn.frame = CGRectMake(10, preMiddleView.height*2/19, preMiddleView.height*10/19, preMiddleView.height*10/19);
- preThumbBtn.frame = CGRectMake(10, 10, preMiddleView.height-20, preMiddleView.height-20);
- [preThumbBtn setImage:[UIImage imageNamed:@"pre_uploadThumb"] forState:0];
- [preThumbBtn addTarget:self action:@selector(doUploadPicture) forControlEvents:UIControlEventTouchUpInside];
- preThumbBtn.layer.cornerRadius = 5.0;
- preThumbBtn.layer.masksToBounds = YES;
- [preMiddleView addSubview:preThumbBtn];
- thumbLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, preThumbBtn.height*0.75, preThumbBtn.width, preThumbBtn.height/4)];
- thumbLabel.textColor = RGB_COLOR(@"#c8c8c8", 1);
- thumbLabel.textAlignment = NSTextAlignmentCenter;
- thumbLabel.text = YZMsg(@"直播封面");
- thumbLabel.font = [UIFont systemFontOfSize:13];
- [preThumbBtn addSubview:thumbLabel];
-
- // UIButton *liveClassBtn = [UIButton buttonWithType:0];
- // liveClassBtn.frame = CGRectMake(preMiddleView.width-80, 0, 70, 30);
- // [liveClassBtn addTarget:self action:@selector(showAllClassView) forControlEvents:UIControlEventTouchUpInside];
- // [preMiddleView addSubview:liveClassBtn];
- // liveClassLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 55, 30)];
- // liveClassLabel.text = YZMsg(@"频道");
- // liveClassLabel.textAlignment = NSTextAlignmentRight;
- // liveClassLabel.textColor = [UIColor whiteColor];
- // liveClassLabel.font = [UIFont systemFontOfSize:14];
- // [liveClassBtn addSubview:liveClassLabel];
- //
- // UIImageView *rightImgView = [[UIImageView alloc]initWithFrame:CGRectMake(liveClassLabel.right+1, 8, 14, 14)];
- // rightImgView.image = [UIImage imageNamed:@"pre_right"];
- // rightImgView.userInteractionEnabled = YES;
- // [liveClassBtn addSubview:rightImgView];
-
- UILabel *preTitlelabel = [[UILabel alloc]initWithFrame:CGRectMake(preThumbBtn.right+10, preThumbBtn.top, 100, preThumbBtn.height/4)];
- preTitlelabel.font = [UIFont systemFontOfSize:13];
- preTitlelabel.textColor = RGB_COLOR(@"#c7c7c7", 1);
- preTitlelabel.text = YZMsg(@"直播标题");
- [preMiddleView addSubview:preTitlelabel];
- liveTitleTextView = [[UITextView alloc]initWithFrame:CGRectMake(preTitlelabel.left, preTitlelabel.bottom, preMiddleView.width-10-preThumbBtn.right, preThumbBtn.height*0.75)];
- liveTitleTextView.delegate = self;
- liveTitleTextView.font = [UIFont systemFontOfSize:20];
- liveTitleTextView.textColor = [UIColor whiteColor];
- liveTitleTextView.backgroundColor = [UIColor clearColor];
- [preMiddleView addSubview:liveTitleTextView];
- textPlaceholdLabel = [[UILabel alloc]initWithFrame:CGRectMake(3, 10, liveTitleTextView.width, 22)];
- textPlaceholdLabel.font = [UIFont systemFontOfSize:20];
- textPlaceholdLabel.textColor = RGB_COLOR(@"#c9c9c9", 1);
- textPlaceholdLabel.text = YZMsg(@"给直播写个标题吧");
- [liveTitleTextView addSubview:textPlaceholdLabel];
-
- UIView *liveclassView = [[UIView alloc]initWithFrame:CGRectMake(10, preMiddleView.bottom+10, _window_width-20, 40)];
- liveclassView.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
- liveclassView.layer.cornerRadius = 5;
- [self addSubview:liveclassView];
-
- UIImageView *classImg = [[UIImageView alloc]init];
- classImg.frame = CGRectMake(10, 13, 20, 14);
- classImg.image = [UIImage imageNamed:@"live_class"];
- classImg.contentMode = UIViewContentModeScaleAspectFit;
- [liveclassView addSubview:classImg];
-
- UIButton *liveClassBtn = [UIButton buttonWithType:0];
- liveClassBtn.frame = CGRectMake(classImg.right+5, 5, liveclassView.width-classImg.right-30, 30);
- [liveClassBtn addTarget:self action:@selector(showAllClassView) forControlEvents:UIControlEventTouchUpInside];
- [liveclassView addSubview:liveClassBtn];
- liveClassLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, liveClassBtn.width, 30)];
- liveClassLabel.text = YZMsg(@"选择直播频道");
- liveClassLabel.textAlignment = NSTextAlignmentLeft;
- liveClassLabel.textColor = [UIColor whiteColor];
- liveClassLabel.font = [UIFont systemFontOfSize:14];
- [liveClassBtn addSubview:liveClassLabel];
- UIImageView *rightImgView = [[UIImageView alloc]initWithFrame:CGRectMake(liveClassBtn.width-20, 8, 14, 14)];
- rightImgView.image = [UIImage imageNamed:@"pre_right"];
- rightImgView.userInteractionEnabled = YES;
- [liveClassBtn addSubview:rightImgView];
- /// 禁用提示
- UILabel *banAlertL = [[UILabel alloc]init];
- banAlertL.textColor = Pink_Cor;
- banAlertL.font = SYS_Font(15);
- banAlertL.numberOfLines = 0;
- banAlertL.text = [YBPower getBanLiveMsg];
- [self addSubview:banAlertL];
- [banAlertL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(liveclassView.mas_bottom).offset(10);
- make.width.equalTo(preMiddleView.mas_width).offset(-20);
- make.centerX.equalTo(preMiddleView);
- }];
- banAlertL.hidden = ![YBPower getBanLiveStatus];
-
- //开播按钮
- UIButton *startLiveBtn = [UIButton buttonWithType:0];
- startLiveBtn.size = CGSizeMake(_window_width*0.8,40);
- startLiveBtn.center = CGPointMake(_window_width*0.5, _window_height*0.8);
- startLiveBtn.layer.cornerRadius = 20.0;
- startLiveBtn.layer.masksToBounds = YES;
- [startLiveBtn setBackgroundColor:Pink_Cor];
- [startLiveBtn addTarget:self action:@selector(clickStartLiveBtn:) forControlEvents:UIControlEventTouchUpInside];
- [startLiveBtn setTitle:YZMsg(@"开始直播") forState:0];
- startLiveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
- [self addSubview:startLiveBtn];
-
- NSArray *functionArr;
- NSArray *functionImgArr;
- NSString *_isshop = minstr([YBPower getIsShop]);
- if ([_isshop isEqual:@"1"]) {
- functionArr = @[YZMsg(@"购物车"),YZMsg(@"翻转"),YZMsg(@"美颜"),YZMsg(@"分享"),YZMsg(@"上热门")];
- functionImgArr = @[@"pre_fun_shop",@"pre_fun_camera",@"pre_fun_meiyan",@"pre_fun_share",@"pre_fun_uphot"];
- _funcTypeArr = @[@(FunctionType_shop),@(FunctionType_camera),@(FunctionType_meiyan),@(FunctionType_share),@(FunctionType_upHot)];
- }else{
- functionArr = @[YZMsg(@"翻转"),YZMsg(@"美颜"),YZMsg(@"分享"),YZMsg(@"上热门")];
- functionImgArr = @[@"pre_fun_camera",@"pre_fun_meiyan",@"pre_fun_share",@"pre_fun_uphot"];
- _funcTypeArr = @[@(FunctionType_camera),@(FunctionType_meiyan),@(FunctionType_share),@(FunctionType_upHot)];
- }
-
- NSArray *shareTypeA = [NSArray arrayWithArray:[common share_type]];
- NSMutableArray *m_functionArr = [NSMutableArray arrayWithArray:functionArr];
- NSMutableArray *m_functionImgArr = [NSMutableArray arrayWithArray:functionImgArr];
- NSMutableArray *m_funcTypeArr = [NSMutableArray arrayWithArray:_funcTypeArr];
-
- if(shareTypeA.count<=0){
- [m_functionArr removeObject:YZMsg(@"分享")];
- [m_functionImgArr removeObject:@"pre_fun_share"];
- [m_funcTypeArr removeObject:@(FunctionType_share)];
- functionArr = [NSArray arrayWithArray:m_functionArr];
- functionImgArr = [NSArray arrayWithArray:m_functionImgArr];
- _funcTypeArr = [NSArray arrayWithArray:m_funcTypeArr];
- }
- UIView *funView = [[UIView alloc]init];
- [self addSubview:funView];
- [funView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(startLiveBtn.mas_top).offset(-20);
- make.centerX.equalTo(startLiveBtn.mas_centerX);
- }];
- for(int i = 0; i < functionArr.count; i ++){
- UIButton *funbtn = [UIButton buttonWithType:0];
- [funbtn addTarget:self action:@selector(funBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- funbtn.tag = 10000+i;
- [funView addSubview:funbtn];
- if(i == 0){
- [funbtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(funView.mas_left).offset(5);
- make.width.height.mas_equalTo(70);
- make.bottom.equalTo(funView.mas_bottom).offset(-10);
- make.top.equalTo(funView.mas_top);
- }];
- openGoodsCar = funbtn;
- openGoodsCar.selected = NO;
- }else{
- if(i == functionArr.count -1){
- [funbtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(funView.mas_left).offset(i * 70);
- make.right.equalTo(funView.mas_right).offset(-5);
- make.top.equalTo(funView.mas_top);
- make.width.mas_equalTo(70);
- }];
- // preTypeBtn = funbtn;
- }else{
- [funbtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(funView.mas_left).offset(i * 70);
- make.top.equalTo(funView.mas_top);
- make.width.mas_equalTo(70);
- }];
- }
- }
-
- UIImageView *img = [[UIImageView alloc]init];
- img.image =[UIImage imageNamed:functionImgArr[i]];
- img.tag = 20000+i;
- [funbtn addSubview:img];
- [img mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(funbtn.mas_centerX);
- make.top.equalTo(funbtn.mas_top);
- make.width.height.mas_equalTo(30);
- }];
- UILabel *titleLb = [[UILabel alloc]init];
- titleLb.textAlignment = NSTextAlignmentCenter;
- titleLb.font = [UIFont systemFontOfSize:14];
- titleLb.textColor = UIColor.whiteColor;
- titleLb.text = functionArr[i];
- titleLb.tag = 30000+i;
- [funbtn addSubview:titleLb];
- [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(funbtn.mas_centerX);
- make.top.equalTo(img.mas_bottom).offset(5);
- }];
- }
- // if ([isShop isEqual:@"1"]) {
- // cartBtn.hidden = NO;
- // }
-
- }
- -(void)funBtnClick:(UIButton *)sender{
- NSInteger index = sender.tag - 10000;
- id aa = _funcTypeArr[index];
- FunctionType type = [aa integerValue];
- if (type == FunctionType_shop) {
-
- // if(UIImageView *img in sender.subviews)
- openGoodsCar.selected = !openGoodsCar.selected;
- _cartOpen = openGoodsCar.selected;
- if(openGoodsCar.selected){
- for (UIImageView *subImg in sender.subviews) {
- if(subImg.tag == sender.tag +10000){
- subImg.image =[UIImage imageNamed:@"pre_fun_shopsel"];
- }
- }
- for (UILabel *subLb in sender.subviews) {
- if(subLb.tag == sender.tag +20000){
- subLb.textColor = Normal_Color;
- }
- }
- }else{
- for (UIImageView *subImg in sender.subviews) {
- if(subImg.tag == sender.tag +10000){
- subImg.image =[UIImage imageNamed:@"pre_fun_shop"];
- }
- }
- for (UILabel *subLb in sender.subviews) {
- if(subLb.tag == sender.tag +20000){
- subLb.textColor = UIColor.whiteColor;
- }
- }
- }
- }else if (type == FunctionType_camera){
- [self rotateCamera];
- }else if (type == FunctionType_meiyan){
- [self showFitterView];
- }else if (type == FunctionType_share){
- NSDictionary *shareDic = @{@"hostName":[Config getOwnNicename],@"thumb_s":[Config getUserAvatarThumb],@"hostId":[Config getOwnID],@"liveTitle":textPlaceholdLabel.text};
- [YBShareView showShareWithType:RKShareType_LivePre parameter:shareDic commplete:^(int codeEvent, NSString *nums) {
-
- }];
- }else if (type == FunctionType_upHot){
- [self toUphot];
- }
- }
- -(void)toUphot{
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-上热门", @"");
- }
- }
- //选择频道
- - (void)showAllClassView{
- YBWeakSelf;
- startLiveClassVC *vc = [[startLiveClassVC alloc]init];
- vc.classID = liveClassID;
- vc.block = ^(NSDictionary * _Nonnull dic) {
- liveClassID = minstr([dic valueForKey:@"id"]);
- liveClassLabel.text = minstr([dic valueForKey:@"name"]);
- [weakSelf setSelClass];
- };
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- // vc.modalPresentationStyle = UIModalPresentationFullScreen;
- // self.animator = [[ZFModalTransitionAnimator alloc] initWithModalViewController:vc];
- // self.animator.bounces = NO;
- // self.animator.behindViewAlpha = 1;
- // self.animator.behindViewScale = 0.5f;
- // self.animator.transitionDuration = 0.4f;
- // vc.transitioningDelegate = self.animator;
- // self.animator.dragable = YES;
- // self.animator.direction = ZFModalTransitonDirectionRight;
- // [self presentViewController:vc animated:YES completion:nil];
- [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:vc animated:YES completion:nil];
- }
- -(void)clickCartBtn:(UIButton *)sender {
- sender.selected = !sender.selected;
- _cartOpen = sender.selected;
- }
- - (void)hidePreTextView{
- [liveTitleTextView resignFirstResponder];
- }
- #pragma mark - 定位开关
- - (void)locationSwitchBtnClick{
- if ([locationLabel.text isEqual:YZMsg(@"开定位")]) {
- loactionImgView.image = [UIImage imageNamed:@"pre_location"];
- locationLabel.text = [cityDefault getLocationCity];
- _locationSwitch = YES;
- }else{
- NSDictionary *contentDic = @{@"title":@"",@"msg":YZMsg(@"关闭定位,直播不会被附近的人看到,直播间人数可能会减少,确认关闭吗?"),@"left":YZMsg(@"取消"),@"right":YZMsg(@"坚决关闭")};
- [YBAlertView showAlertView:contentDic complete:^(int eventType) {
- if (eventType == 1) {
- loactionImgView.image = [UIImage imageNamed:@"pre_location_off"];
- locationLabel.text = YZMsg(@"开定位");
- _locationSwitch = NO;
- }
- }];
- }
- }
- #pragma mark - 切换
- -(void)rotateCamera {
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-切换", @"");
- }
- }
- - (void)doClosePreView {
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-关闭", @"");
- }
- }
- -(void)clickStartLiveBtn:(UIButton *)sender {
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-开直播", @"");
- }
- }
- -(void)showFitterView {
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-美颜", @"");
- }
- }
- -(void)setSelClass{
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-分类", liveClassID);
- }
- }
- - (void)share:(UIButton *)sender{
- if ([selectShareName isEqual:sender.titleLabel.text]) {
- sender.selected = NO;
- selectShareName = @"";
- }else{
- sender.selected = YES;
- selectShareName = sender.titleLabel.text;
- for (UIButton *btn in preShareBtnArray) {
- if (btn != sender) {
- btn.selected = NO;
- }
- }
- }
- if (self.livePreEvent) {
- self.livePreEvent(@"预览-分享", selectShareName);
- }
- }
- -(void)doUploadPicture{
-
- /*
- YBWeakSelf;
- RKActionSheet *sheet = [[RKActionSheet alloc]initWithTitle:@""];
- [sheet addActionWithType:RKSheet_Default andTitle:YZMsg(@"相机") complete:^{
- [weakSelf selectThumbWithType:UIImagePickerControllerSourceTypeCamera];
- }];
- [sheet addActionWithType:RKSheet_Default andTitle:YZMsg(@"相册") complete:^{
- [weakSelf selectThumbWithType:UIImagePickerControllerSourceTypePhotoLibrary];
- }];
- [sheet addActionWithType:RKSheet_Cancle andTitle:YZMsg(@"取消") complete:^{
- }];
- [sheet showSheet];
- */
- //安卓直接跳相册->去掉弹窗2020-7-2
- [self selectPhotos];
- }
- -(void)selectPhotos {
- TZImagePickerController *imagePC = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
- imagePC.preferredLanguage = [lagType isEqual:ZH_CN] ? @"zh-Hans":@"en";
- imagePC.showSelectBtn = YES;
- imagePC.allowCrop = NO;
- imagePC.allowPickingOriginalPhoto = NO;
- imagePC.oKButtonTitleColorNormal = Pink_Cor;
- imagePC.allowTakePicture = YES;
- imagePC.allowTakeVideo = NO;
- imagePC.allowPickingVideo = NO;
- imagePC.allowPickingMultipleVideo = NO;
- imagePC.modalPresentationStyle = 0;
- [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:imagePC animated:YES completion:nil];
- }
- - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{
- _thumbImage = photos[0];
- [preThumbBtn setImage:_thumbImage forState:UIControlStateNormal];
- thumbLabel.text = YZMsg(@"更换封面");
- thumbLabel.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
- }
- -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
- NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
- if ([type isEqualToString:@"public.image"])
- {
- //先把图片转成NSData
- UIImage* image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
- _thumbImage = image;
- [preThumbBtn setImage:image forState:UIControlStateNormal];
- thumbLabel.text = YZMsg(@"更换封面");
- thumbLabel.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
- }
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
- if ([UIDevice currentDevice].systemVersion.floatValue < 11) {
- return;
- }
- if ([viewController isKindOfClass:NSClassFromString(@"PUPhotoPickerHostViewController")]) {
- [viewController.view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- if (obj.frame.size.width < 42) {
- [viewController.view sendSubviewToBack:obj];
- *stop = YES;
- }
- }];
- }
- }
- - (void)textViewDidChange:(UITextView *)textView {
- if (textView.text.length == 0) {
- textPlaceholdLabel.text = YZMsg(@"给直播写个标题吧");
- }else{
- textPlaceholdLabel.text = @"";
- }
- _inputTitleStr = textView.text;
- }
- @end
|