标签: quartz-core

为什么Xcode在项目使用时不会自动与QuartzCore链接?

我对使用Xcode开发iOS应用程序感到有点好奇,尽管我们特别指出:

#import <QuartzCore/QuartzCore.h>
Run Code Online (Sandbox Code Playgroud)

在我们ViewController.h的项目链接时,QuartzCore库不会自动链接.这是为什么?

iphone xcode ios quartz-core

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

CALayer作为SubLayer不可见

我正在尝试构建一个动画圆圈,它将顺时针绘制,直到它变成完整的圆圈,如iPhone核心动画 - 绘制圆圈所示

问题是CALayer没有添加或构建对象.我测试过并发现它没有访问我drawInContext:CGContextRefanimatingArc方法.

到目前为止我所做的是:

在AnimateArc.h中

@interface AnimateArc : CALayer {

CAShapeLayer *circle;
}

-(void) animatingArc;

@end
Run Code Online (Sandbox Code Playgroud)

在AnimateArc.m中

-(void) drawInContext:(CGContextRef)ctx
{
CGFloat radius = 50.0;
circle = [CAShapeLayer layer];

//make a circular shape
circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0.0, 0.0, 2 * radius, 2 * radius) cornerRadius:radius].CGPath;

    CGPoint centerPoint = CGPointMake(CGRectGetWidth(self.bounds)/2, CGRectGetHeight(self.bounds)/2);    

//center the shape in self.view
circle.position = centerPoint;

//configure appearence of circle
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor blackColor].CGColor;
circle.lineWidth = 5; …
Run Code Online (Sandbox Code Playgroud)

invisible core-animation ios4 quartz-core

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

UITableView不响应透明区域的触摸

我有一个UITableView透明的backgroundColor,里面的单元格用以下代码初始化

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
  self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  if (self) {
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, CGRectGetWidth(self.contentView.frame), 180)];
    self.label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    self.label.text = @"test";
    [self.contentView addSubview:self.label];
  }
  return self;
}
Run Code Online (Sandbox Code Playgroud)

每行的高度为200,标签不会填满整个单元格.每个单元格之间将有透明部分.当我尝试通过触摸那些透明部分来滚动表格时,触摸完全被忽略.我知道,从iOS5开始,对视图的触摸将被忽略.我该怎么做才能解决这个问题?

我尝试过的东西不起作用:

设置透明或隐藏或alpha = 0 UIView作为tableView的假背景

相同的交易,触摸被忽略.

UIView在tableView上创建子类,子类UIView使用tableView作为nextResponder

显然UITableView不使用touchesBegan/cancelled/ends/moved,所以这不起作用.我不认为实现我的滚动方法是明智的UITableView.

将tableView的backgroundColor设置为 [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1]

我不想这样做,它仍然可见.

简而言之,即使我从透明部分开始滚动,我还能做什么来滚动表?

objective-c uitableview ios quartz-core

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

围绕中心点旋转UIView而不旋转视图本身

我想在不旋转UIView本身的情况下围绕中心点旋转UIView.所以更像是摩天轮的车(总是保持直立),而不是钟表的手.

我围绕中心点旋转UIViews的时间,我使用了图层位置/ anchorPoint /变换来完成效果.但这显然会改变视图本身的方向.

有帮助吗?

凯勒

objective-c uiview ios quartz-core

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

可能在归属文本背景上有圆角吗?

我将Text归为不同的文本颜色.为了更好地阅读突出显示的文本,我使用backgroundcolor.是否有可能在这个Textarea上带来圆角的CALayer效果?不是整个区域,而是内部的特殊文本.

我的代码:

NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"Highlighted Text"
                                                                          attributes:@{
                                                                                       NSFontAttributeName:            [UIFont fontWithName:@"HelveticaNeue" size:10.0f],
                                                                                       NSForegroundColorAttributeName: [UIColor lightGrayColor],
                                                                                       NSBackgroundColorAttributeName: [UIColor darkGrayColor]
                                                                                       }];
Run Code Online (Sandbox Code Playgroud)

iphone nsattributedstring uilabel ios quartz-core

5
推荐指数
0
解决办法
5675
查看次数

ImageView的人脸检测和缩放因缩放而无法正常工作?

我再次接近,但没有香蕉.

我正在尝试按照面部识别的一些教程.几乎有以下代码,但我认为有些东西我不知道它是如何缩放和在UIImageView边缘周围放置边框.

我在照片库中的照片大小不一(出于某种莫名其妙的原因),所以我想象的CIDetector是找到面孔,我正在应用CGAffineTransforms等等,并试图将它们放入UIImageView.但是,正如您从图像(也在下面)中看到的那样,它并没有被绘制到正确的位置.

UIImageView是280x500并设置为Scale to Fill.

任何有助于解决正在发生的事情的帮助都会很棒!

-(void)detectFaces {

    CIContext *context = [CIContext contextWithOptions:nil];
    CIImage *image = [CIImage imageWithCGImage:_imagePhotoChosen.image.CGImage options:nil];
    CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace context:context options:@{CIDetectorAccuracy : CIDetectorAccuracyHigh}];
    CGAffineTransform transform = CGAffineTransformMakeScale(1, -1);
    transform = CGAffineTransformTranslate(transform, 0, -_imagePhotoChosen.image.size.height);
    NSArray *features = [detector featuresInImage:image];
    NSLog(@"I have found %lu faces", (long unsigned)features.count);
    for (CIFaceFeature *faceFeature in features)
    {   
        const CGRect faceRect = CGRectApplyAffineTransform(faceFeature.bounds, transform);
        NSLog(@"I have the original frame as: %@", …
Run Code Online (Sandbox Code Playgroud)

objective-c core-image uiimageview ios quartz-core

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

自定义CALayer - 无效的上下文0x0

我正在尝试构建一个使用图层的应用程序,我的应用程序结构是

UIView --> UIScrollView --> UIView --> LayersView (Custom UIView)
                                   --> UIImageView
Run Code Online (Sandbox Code Playgroud)

我想多层添加到LayersView,所以我建立一个自定义CALayer使用UIBezierPath绘制一组点.

CALayerBezierPath.h

#import <QuartzCore/QuartzCore.h>

@interface CALayerBezierPath : CALayer {
    NSMutableArray *pointsArray;
}
@property (nonatomic, retain) NSMutableArray *pointsArray;

- (void) initVariables;
- (void) addNewPoints:(CGPoint)newPoint;
@end
Run Code Online (Sandbox Code Playgroud)

CALayerBezierPath.m

#import "CALayerBezierPath.h"

@implementation CALayerBezierPath

@dynamic pointsArray;

-(void)drawInContext:(CGContextRef)ctx {
    NSLog(@"CALayerBezierPath - drawInContext");
    if ([pointsArray count] > 0) {
        UIColor *color = [UIColor redColor];
        [color set];
        UIBezierPath *path = [UIBezierPath bezierPath];
        [path moveToPoint:[[pointsArray objectAtIndex:0] CGPointValue]];
        for (int x = 1; x …
Run Code Online (Sandbox Code Playgroud)

calayer cgcontext ios5 quartz-core

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

Objective-C:捕获自定义框架内所有视图的屏幕截图

我有一个游戏,用户可以创建自定义级别并上传到我的服务器供其他用户玩,我想在用户测试他/她的级别上传到我的服务器之前获取"操作区域"的屏幕截图一个"预览图像".

我知道如何获取整个视图的屏幕截图,但我想将其定义为自定义框架.请考虑以下图像:

行动区

我想用红色区域截取屏幕截图,即"动作区域".我能做到吗?

screenshot objective-c ios quartz-core

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

使用swift移动和动画UIImageView

我这里有一个相当简单的问题.基本上我正在尝试将一个对象(一个UIImageView)从A点(它在故事板中设置)移动到我以编程方式定义的B点.

我的第一次传递导致了这段代码

        UIView.animateWithDuration(0.75, delay: 0.5, options: UIViewAnimationOptions.CurveLinear, animations: {
            self.signInButton.alpha = 1
            self.signInButton.center.y = 10
        }, completion: nil)
Run Code Online (Sandbox Code Playgroud)

但是,此代码的作用基本上是将按钮偏离中心,然后再返回其原始位置.

然后我调查了QuartzCore来帮助我,但一切都在Objective-C中.我有这个方法:

    func moveImage(view: UIImageView){
        var toPoint: CGPoint = CGPointMake(0.0, -10.0)
        var fromPoint : CGPoint = CGPointZero

        var movement = CABasicAnimation(keyPath: "movement")
        movement.additive = true
        movement.fromValue = fromPoint
        movement.toValue = toPoint
        movement.duration = 0.3

        view.layer.addAnimation(movement, forKey: "move")
    }
Run Code Online (Sandbox Code Playgroud)

但是这里的问题是movement.fromValue不能接受的CGPoint.我知道在目标C中有一个函数将a转换CGPoint为a NSValue,但是这个函数似乎是从Swift中弃用的,我找不到另一种方法.

因此,我的问题是,如何转换CGPointNSValue使我的moveImage()功能工作,还是有更好的方法将对象从A点移动到B点?

谢谢!

我正在看这个问题Animate UIImage在UIImageView Up&Down(喜欢它的悬停)循环

uiimageview quartz-core swift ios8

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

两个视图之间的自定义循环过渡

我想创建一个类似于动画的动画,用于在Spy Mouse应用程序中更改不同视图之间的动画.观看此视频以供参考:

http://www.youtube.com/watch?v=ylFdl7W3Srw

圆形动画的截图

我不能这样做.我的动画显示的是矩形区域而不是圆形视图.

CABasicAnimation *cornerRadiusAction = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];    

cornerRadiusAction.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
cornerRadiusAction.duration = 5.0f;
cornerRadiusAction.toValue = [NSNumber numberWithFloat:self.view.bounds.size.height*2];
[self.view.layer addAnimation:cornerRadiusAction forKey:nil];
Run Code Online (Sandbox Code Playgroud)

cabasicanimation ios quartz-core

4
推荐指数
2
解决办法
1373
查看次数