小编Gra*_*nit的帖子

将渐变颜色应用于使用UIBezierPath创建的弧

我想创建一个具有弧形的进度条.进度条的颜色必须根据值进行更改.

我使用创建了一个弧UIBezierPath bezierPathWithArcCenter.我使用了以下代码:

- (void)viewDidLoad
{
    [super viewDidLoad];

    int radius = 100;

    CAShapeLayer *arc = [CAShapeLayer layer];

    arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:60.0 endAngle:0.0 clockwise:YES].CGPath;

    arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
                                  CGRectGetMidY(self.view.frame)-radius);

    arc.fillColor = [UIColor clearColor].CGColor;
    arc.strokeColor = [UIColor purpleColor].CGColor;
    arc.lineWidth = 15;

    [self.view.layer addSublayer:arc];

    CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
    drawAnimation.duration            = 5.0; // "animate over 10 seconds or so.."
    drawAnimation.repeatCount         = 1.0;  // Animate only once..
    drawAnimation.removedOnCompletion = NO;   // Remain stroked after the animation..
    drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; …
Run Code Online (Sandbox Code Playgroud)

xcode uicolor ios uibezierpath

25
推荐指数
2
解决办法
1万
查看次数

根据Radius Google Maps iOS SDK更改相机缩放

我正在开发一个应用程序,根据您当前位置的半径显示某些标记.半径在100到5000米之间.我用a改变半径UISlider并重新绘制GMSCircle.

我的问题是我想根据滑块值更新相机变焦,但我不知道要分割的比例.

这是我viewDidLoad在初始缩放值为15 的方法中创建相机的方法:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:locationManager.location.coordinate.latitude longitude:locationManager.location.coordinate.longitude  zoom:15];
Run Code Online (Sandbox Code Playgroud)

这是我正在做的工作的截图.

在此输入图像描述

有谁知道我应该使用什么比例来相应地移动缩放?

非常感谢!

格兰尼特

iphone ios google-maps-sdk-ios

9
推荐指数
3
解决办法
7228
查看次数

将圆角应用于使用UIBezierPath创建的弧

我正在使用UIBezierPath创建的循环进度条.进度条如下图所示:

在此输入图像描述

我的问题是:如何使圆弧的边缘变圆而不是矩形?

我用来绘制弧线的代码如下:

 // Draw the arc with bezier path
        int radius = 100;

        arc = [CAShapeLayer layer];
        arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:M_PI endAngle:M_PI/150 clockwise:YES].CGPath;
        arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
                                    CGRectGetMidY(self.view.frame)-radius);
        arc.fillColor = [UIColor clearColor].CGColor;
        arc.strokeColor = [UIColor purpleColor].CGColor;
        arc.cornerRadius = 0.5;
        arc.lineWidth = 6;

        [self.view.layer addSublayer:arc];

        // Animation of the progress bar
        drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
        drawAnimation.duration            = 5.0; // "animate over 10 seconds or so.."
        drawAnimation.repeatCount         = 1.0;  // Animate only once..
        drawAnimation.removedOnCompletion = YES;   // Remain stroked …
Run Code Online (Sandbox Code Playgroud)

objective-c uibezierpath

8
推荐指数
2
解决办法
2574
查看次数

AVPlayer不会在iOS9中播放来自网址的视频

我试图在UIView中嵌入AVPlayer并从网址播放mp4视频文件.问题是我只收到一个黑色的空白视图(见截图)

在此输入图像描述

在以前的iOS版本中,它对我有用,但自从升级到iOS9后我遇到了这个问题.

我的.h文件看起来像这样:

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *viewPlayerContainer;
Run Code Online (Sandbox Code Playgroud)

而在我的实现文件中,我有以下内容:

@import AVFoundation;
@import AVKit;

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];

    NSURL *url = [NSURL URLWithString:@"http://techslides.com/demos/sample-videos/small.mp4"];

    AVURLAsset *asset = [AVURLAsset assetWithURL: url];
    AVPlayerItem *item = [AVPlayerItem playerItemWithAsset: asset];

    AVPlayer * player = [[AVPlayer alloc] initWithPlayerItem: item];

    [playerViewController.view setFrame:CGRectMake(0, 0, _viewPlayerContainer.bounds.size.width, _viewPlayerContainer.bounds.size.width)];

    playerViewController.showsPlaybackControls = NO;

    [_viewPlayerContainer addSubview:playerViewController.view];


    [player play];


}
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

提前致谢!

xcode ios avplayer

7
推荐指数
1
解决办法
2万
查看次数

如何通过 CocoaPods 使用本地项目

我正在努力寻找一种方法将我们创建的 Xcode 框架打包为一个只能在内部使用的 Pod(不是公开的,也不是在 github 上)。

如何修改.podspec以从我的开发机器上的本地 Xcode 项目构建 SDK?

xcode objective-c ios cocoapods podspec

5
推荐指数
2
解决办法
6446
查看次数

水平滚动查看iOS

我想询问是否可以水平使用UIScrollView.我有一个播放不同电台的应用程序,每个电台由UIButton代表.我怎么能连续放置3个按钮,所以当我滚动另外三个UIButton出现?

下面你可以看到设计应该是什么样子.

非常感谢你!

在此输入图像描述

objective-c uibutton uiscrollview ios

2
推荐指数
1
解决办法
2万
查看次数

自定义UITabBar图标iOS

我正在开发一个选项卡式应用程序,我想集成自定义UITabbar背景和图标.我已经插入了自定义背景,但我的图标有问题.

这是图标的外观:

在此输入图像描述

但在为故事板中的每个视图添加图标后,我得到如下灰色图标:

在此输入图像描述

有谁知道为什么图标以这种方式显示?

非常感谢你!

xcode uitabbarcontroller ios

2
推荐指数
1
解决办法
2万
查看次数

调用popViewControllerAnimated后,UITableview滚动到顶部

我遇到了一个问题UITableView.

我正在显示一系列跟踪记录.用户点击单元格后,将显示详细视图控制器,其中包含详细数据.我的问题是在popViewControllerAnimated:YES从详细信息视图控制器调用后,我的表视图被重置并自动滚动到顶部位置.

我不打电话[myTable reloadData];viewWillAppear,我觉得这种行为有点怪异.

有谁知道我在这里可能缺少什么?

任何帮助或提示将不胜感激!

谢谢,Granit

xcode uitableview ios

1
推荐指数
1
解决办法
773
查看次数