美文网首页
UIActivityIndicatorView和UIActivi

UIActivityIndicatorView和UIActivi

作者: Steven_Wu | 来源:发表于2017-03-20 13:29 被阅读45次

    UIActivityIndicatorView是一个等待指示器(菊花)。

    //在.h中声明一个属性:
    @property (nonatomic, strong)UIActivityIndicatorView *activityIndicatorView;
    
    //在.m中初始化:
       _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
        _activityIndicatorView.center = self.view.center;
        _activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        
      [self.view addSubview:_activityIndicatorView];
    
    //在需要用的地方:
    [_activityIndicatorView startAnimating]; //开始
    [_activityIndicatorView stopAnimating]; //停止
    

    UIActivityViewController是苹果自带的分享页面,类似友盟分享,但不需要到第三方平台申请AppKey,直接分享,十分方便。其分享图片需要将图片转为NSData,分享视频只需拿到视频的URL即可。

    - (void)shareVideo {
            NSURL *URL = [NSURL fileURLWithPath:_assetModel.filePath];
            UIActivityViewController *activityVc = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:nil];
            [self presentViewController:activityVc animated:YES completion:nil];
    }
    

    相关文章

      网友评论

          本文标题:UIActivityIndicatorView和UIActivi

          本文链接:https://www.haomeiwen.com/subject/vflwwttx.html