小编Ale*_*dro的帖子

将CAShapeLayer蒙版应用于UIView

我正在使用此代码将图层应用于UIview:

mask = [[CAShapeLayer alloc] init];
mask.frame = baseView.layer.bounds;
CGRect biggerRect = CGRectMake(mask.frame.origin.x, mask.frame.origin.y, mask.frame.size.width, mask.frame.size.height);
CGRect smallerRect = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);

UIBezierPath *maskPath = [UIBezierPath bezierPath];
[maskPath moveToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMaxY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMaxY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMinY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))];

[maskPath moveToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMaxY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMaxY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMinY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))];

mask.path = maskPath.CGPath;
[mask setFillRule:kCAFillRuleEvenOdd];
mask.fillColor = [[UIColor blackColor] CGColor];
baseView.layer.mask = mask;
Run Code Online (Sandbox Code Playgroud)

由于我要剪切的矩形发生了变化,我很想知道是否有一种快速方法可以更改蒙版的大小,而不是仅仅从UIview中删除它并使用不同的尺寸重新应用它:

例如

[mask removeFromSuperlayer];
Run Code Online (Sandbox Code Playgroud)

和...

mask = [[CAShapeLayer alloc] …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uiview cashapelayer ios

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

UISlider平滑地改变价值

我有一个UIslider设置AVAdioRecording的位置:

CGRect frame = CGRectMake(50.0, 230.0, 200.0, 10.0);
                     aSlider = [[UISlider alloc] initWithFrame:frame];
                     // Set a timer which keep getting the current music time and update the UISlider in 1 sec interval
                     sliderTimer = [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(updateSlider) userInfo:nil repeats:YES];
                     // Set the maximum value of the UISlider
                     aSlider.maximumValue = player.duration;
                     // Set the valueChanged target
                     [aSlider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
                     [self.ViewA addSubview:aSlider];




 - (void)updateSlider {
// Update the slider about the music time

[UIView beginAnimations:@"returnSliderToInitialValue" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:1.3]; …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uislider ios

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

获取NSString的前两个字符

我有一个字符串,我试图获得前2个字符和字符串的其余部分.这就是我试图这样做的方式:

NSString *textAll = [arrayOfMessages objectAtIndex:indexPath.row];
NSString *textMessage = [textAll substringFromIndex:2];
NSString *textType = [textAll substringToIndex:1];
Run Code Online (Sandbox Code Playgroud)

textAll有这样的形式:消息本身.....

textType应该返回'HE'textMessage应该返回'消息本身.....'Textmessage现在给我消息,但我似乎无法获取textType ...

ios

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

iphone 5 4英寸

可能重复:
如何检测iPhone 5(宽屏设备)?

我正在使用Xcode创建一个应用程序.我注意到使用xcode 4.5,你的故事板可以适应iphone 5的屏幕尺寸.如果我创建两个具有不同屏幕大小的独立故事板,但将控制器链接到相同的.h文件,如何根据设备告诉程序加载哪个故事板?

例如:对于ipad,当我运行时,它会自动选择正确的故事板

xcode ios

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

继续在后台IOS中上传过程

我想知道是否可以继续在后台上传文件.例如,当用户将iPad置于睡眠状态时,继续上传...

我在Dropbox论坛中也问过这个问题,因为我使用核心API上传到Dropbox.这就是答案:

"使用核心API,上传完全由您的应用程序控制.您可以请求操作系统在后台保持您的应用程序活动,在暂停您的应用程序之前最多允许10分钟.您可以看到更多信息这里:https: //developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html 如果您使用新的Sync API,这将由API自动完成."

我在这里发帖是因为我不明白他们的意思是'要求操作系统让你的应用程序在后台运行'.这是否意味着我必须向ios请求特定的代码,它与dropbox无关,或者它是一个特定的Dropbox功能?

dropbox ios

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

removeFromParentNode()SceneKit中的EXC_BAD_ACCESS

我在游戏执行过程中随机弹出以下错误:

在此输入图像描述

我正在随机的时刻创建carNode的多个实例,并且所有这些实例都有从场景中删除节点的操作.大多数情况下这不是问题,但在某些情况下,应用程序会因照片中显示的错误而崩溃.看起来我可以在这些情况下得到错误:

对象未初始化对象已被释放其他不太可能发生的对象

..除了第一个,我更确定我没有提前发布对象..那么它会是什么?

这是完整的代码:

func spawnCarAtPosition(position: SCNVector3) {

    // Create a material using the model_texture.tga image
    let carMaterial = SCNMaterial()
    carMaterial.diffuse.contents = UIImage(named: "assets.scnassets/Textures/model_texture.tga")
    carMaterial.locksAmbientWithDiffuse = false

    // Create a clone of the Car node of the carScene - you need a clone because you need to add many cars
    var carNode: SCNNode!
    let randomNumb = AppDelegate().randRange(0, upper: beachCarArray.count -     1)
    let selectedObject = beachCarArray[randomNumb]
    carNode = selectedObject.objectscene.rootNode.childNodeWithName(selectedObject.objectname, recursively: false)!.clone() as SCNNode
    carNode.name = selectedObject.objectname
    carNode.position = position

    // …
Run Code Online (Sandbox Code Playgroud)

scenekit

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

UI按钮闪烁动画

我想知道是否可以将闪烁动画应用于UI按钮.我在互联网上搜索过,但只找到了脉冲动画的代码,它不断改变我的Uibutton的大小.我改为考虑某种闪烁动画来提醒用户他必须按下按钮.我能想到的问题的唯一方法是使用以下方法不断更改alpha:

[self setAlpha:0.5]; 
Run Code Online (Sandbox Code Playgroud)

...但它不会像闪烁按钮那样可见.

animation uikit ios

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

架构armv7s找不到符号(链接器命令失败,退出代码为1)

当我为IOS7构建Xcode 5时,我收到此错误:

Undefined symbols for architecture armv7s:
  "_OBJC_CLASS_$_CIFilter", referenced from:
      objc-class-ref in UIImage+Filter.o
  "_kCIInputImageKey", referenced from:
      -[UIImage(Filter) filterWithPreset:] in UIImage+Filter.o
  "_OBJC_CLASS_$_CIImage", referenced from:
      objc-class-ref in UIImage+Filter.o
  "_OBJC_CLASS_$_CIContext", referenced from:
      objc-class-ref in UIImage+Filter.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我注意到如果删除UIImage + Filter.h/m文件和UIImageView + Filter.h/m,错误就会消失

objective-c linker-errors

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

在应用程序进入后台时中断 SceneKit 场景

当我的游戏进入后台模式时,我想完全暂停游戏。目前这就是我所做的:

在 AppDelegate 中:

func applicationWillResignActive(application: UIApplication) {
    gameViewControllerDelegate?.pauseGame()
}
Run Code Online (Sandbox Code Playgroud)

在我的游戏控制器中:

func pauseGame() {
    buttonPausePressed(buttonPausePlay)
}

func buttonPausePressed(sender: UIButton!) {
    scnView?.scene?.paused = true
    stopMusic()
    let exampleImage = UIImage(named: "16-play")?.imageWithRenderingMode(.AlwaysTemplate)
    sender.setImage(exampleImage, forState: UIControlState.Normal)
}
Run Code Online (Sandbox Code Playgroud)

该方法被调用并更改按钮的图像。连比赛都暂停了。但是当我再次打开应用程序并使用以下命令取消暂停时:

scnView?.scene?.paused = false
Run Code Online (Sandbox Code Playgroud)

所有的图形变化和其他奇怪的事情都会发生。似乎 SCNActions 从未暂停过。有任何想法吗?

ios scenekit

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

Kubectl 将部署应用到指定的节点组 - ​​AWS EKS

我在EKS 集群中创建了多个堆栈(节点组),每个组在不同的实例类型上运行(例如,一组在 GPU 实例上运行)。我在aws-auth-cm.yaml文件的mapRoles中为每个节点组添加了一个条目。现在我想在另一个部署上部署一些部署。部署文件看起来像这样:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-1
spec:
  replicas: 1
  selector:
    matchLabels:
      component: component-1
  template:
    metadata:
      labels:
        component: component-1
    spec:
      containers:
        - name: d1
          image: docker-container
          ports:
            - containerPort: 83
Run Code Online (Sandbox Code Playgroud)

文档显示我可以运行标准命令kubectl apply。有什么办法可以指定组吗?也许像

kubectl apply -f server-deployment.yaml -group node-group-1

amazon-web-services kubernetes amazon-eks

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