标签: quartz-core

CAShapeLayer动画(弧度从0到最终大小)

我有一个CAShapeLayer使用的弧添加UIBezierPath.我在stackoverflow上看到了几个帖子(实际上有一个),但似乎没有人给我答案.如标题中所述,我想为一个圆弧设置动画(是的,它将用于饼图).

如何从"空"弧到完全扩展的弧完成动画?有点像弯曲的进度条.通过它真的不可能CoreAnimation吗?

这是我"做"弧的方式.哦,忽略评论和计算,因为我习惯于逆时针单位圆,苹果顺时针方向.弧线看起来很好,我只需要动画:

    //Apple's unit circle goes in clockwise rotation while im used to counter clockwise that's why my angles are mirrored along x-axis
    workAngle = 6.283185307 - DEGREES_TO_RADIANS(360 * item.value / total);

    //My unit circle, that's why negative currentAngle
    [path moveToPoint:CGPointMake(center.x + cosf(outerPaddingAngle - currentAngle) * (bounds.size.width / 2), center.y - (sinf(outerPaddingAngle - currentAngle) * (bounds.size.height / 2)))];

    //Apple's unit circle, clockwise rotation, we add the angles
    [path addArcWithCenter:center radius:120 startAngle:currentAngle endAngle:currentAngle + …
Run Code Online (Sandbox Code Playgroud)

animation core-animation objective-c ios quartz-core

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

如何在Swift中导入QuartzCore.framework?

我需要QuartzCore.framework来将borderColor添加到文本字段中,怎么样?

cglayer ios quartz-core swift

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

如何为UINavigation栏添加阴影效果

在此输入图像描述

您好,我想为我添加这种阴影我该NAvigationBar怎么做.

这就是我尝试添加阴影的方式.

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage=[UIImage new];

self.navigationController.navigationBar.translucent=YES;

self.navigationController.navigationBar.topItem.titleView.tintColor=[UIColor whiteColor];
self.navigationController.navigationBar.titleTextAttributes=[NSDictionary dictionaryWithObject:[UIFont fontWithName:@"HelveticaNeue" size:15.0f] forKey:NSFontAttributeName];
self.navigationController.navigationBar.topItem.title=strNavigtionTitle;
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"backarrow"] style:UIBarButtonItemStylePlain target:self action:@selector(revealToggle :)];
[self.navigationController navigationBar].tintColor = [UIColor whiteColor];

[self.navigationController navigationBar].layer.shadowColor=[UIColor colorWithRed:53.0/255.0 green:108.0/255.0 blue:130.0/255.0 alpha:1.0f].CGColor;
[self.navigationController navigationBar].layer.shadowOffset=CGSizeMake(0, 20);
[self.navigationController navigationBar].layer.shadowOpacity=0.8;
[self.navigationController navigationBar].layer.shadowRadius=5.5;
Run Code Online (Sandbox Code Playgroud)

但这只会为箭头和我的Apply Leave标题添加阴影.但是我想添加一个像这个图像中的阴影.它应该在NavigationBar和我的主要之间UIView我该怎么做?请帮我.谢谢

uinavigationbar dropshadow ios quartz-core

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

containsPoint:用于UIBezierPath崩溃

我正在解析SVG文件UIBezierPath.我想知道a CGPoint是在内部还是外部UIBezierPath.为此,我使用containsPoint:.当我在模拟器中运行时,everthing工作正常(差不多!).当我运行iPad设备时,它会在某些路径和点上崩溃.我打电话之前我closePathUIBezierPath在打电话containsPoint:.

以下是一些路径和点,这会导致崩溃(我将点随机化,因此可能会有更多崩溃点):

Crash Points: (659.0, 444.0), (659.0, 443.0)
SVG Path: M661 446 c1 -1 3 -1 4 -1 1 -1 2 -2 2 -4 0 -2 0 -2 -2 -2 0 1 -2 1 -3 1 -2 0 -3 1 -3 2 0 1 0 2 0 3 0 0 1 1 2 1z

Crash Points: (533.0, 458.0), (533.0, 457.0)
SVG Path: M535 460 c0 0 …
Run Code Online (Sandbox Code Playgroud)

objective-c ios quartz-core

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

为什么小于1.0pts的线在非视网膜屏幕上无法正确渲染?

self.layer.borderWidth = 0.5;
Run Code Online (Sandbox Code Playgroud)

在视网膜屏幕上UIButtonUITextField在视网膜屏幕上呈现精细,但在非视网膜屏幕上,只有顶部和左侧边框呈现,而右边框和底部边框不呈现.

我假设它与屏幕的dpi以及如何绘制子点线有关,但可能有更好的解释.

问题: 我想知道是否有可能UIView在视网膜和非视网膜屏幕上borderWidth设置的边界显示的所有边都设置为0.5.

ios retina-display quartz-core

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

CALayer autoresizingMask不适用于iOS SDK?

我注意到,iOS SDK上的CALayer没有autoresizingMask属性.我不确定自动调整动画子图层的方法"setFrame:"的自定义重载是否可以正常工作.有没有使用UIView的替代方案?

core-animation calayer ios quartz-core

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

视网膜和非视网膜设备上的renderInContext

我通过拍摄UIView的截图来创建PDF,目前在带有视网膜显示屏的iPad3上工作得很好,但是当在其他具有较低分辨率屏幕的设备上进行测试时,我遇到文本分辨率问题.

这是我的代码:

    //start a new page with default size and info
    //this can be changed later to include extra info.
    UIGraphicsBeginPDFPage();

    //render the view's layer into an image context
    //the last option specifies scale. If 0, it uses the devices scale.
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 2.0);

    CGContextRef context = UIGraphicsGetCurrentContext();
    [view.layer renderInContext:context];
    UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    //render the screenshot into the pdf page CGContext
    [screenShot drawInRect:view.bounds];

    //close the pdf context (saves the pdf to the NSData object)
    UIGraphicsEndPDFContext();
Run Code Online (Sandbox Code Playgroud)

我也尝试将UIGraphicsBeginImageContextWithOptions比例设置为2.0,但这没有任何变化.如何强制iPad2上的视图以2倍的分辨率渲染? …

objective-c calayer uikit quartz-core

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

为UIView添加褪色和透明度

我知道如何制作和动画像一个在谈到与iOS新应用程序商店应用程序的共享子图的图6+(见附件截图),但我不知道如何添加漂亮的透明度着色效果在这个观点上.任何人都可以提供代码示例,使其UIView看起来与截图中的完全相同?

PS alphaUIView独有的属性不做这样的事情.

在此输入图像描述

iphone objective-c uiview ios quartz-core

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

用于iphone应用的图像颜色替换

基本上我想为我的涂料应用实现颜色替换功能.以下是原始和预期的输出

原版的: 原版的

更改用户选择的墙面颜色以及一些更换阈值后

期望的输出 我尝试了两种方法,但无法按预期工作

方法1:
基于队列的洪水填充算法用于颜色替换,但是我得到的输出低于非常缓慢的墙壁阴影并且没有保留.

洪水填充输出

方法2: 所以我试着看另一个选项,发现下面的帖子来自SO 如何更改图像中的特定颜色?

但我无法理解逻辑,也不确定我在第3步中的代码实现.

根据我的理解,请在每个步骤中找到以下代码.

1)使用cvCvtColor将图像从RGB转换为HSV(我们只想更改色调).

 IplImage *mainImage=[self CreateIplImageFromUIImage:[UIImage imageNamed:@"original.jpg"]];
 IplImage *hsvImage = cvCreateImage(cvGetSize(mainImage), IPL_DEPTH_8U, 3);
 IplImage *threshImage = cvCreateImage(cvGetSize(mainImage), IPL_DEPTH_8U, 3);
 cvCvtColor(mainImage,hsvImage,CV_RGB2HSV);
Run Code Online (Sandbox Code Playgroud)

2)使用cvThreshold隔离颜色,指定一定的容差(您想要一系列颜色,而不是一种颜色).

cvThreshold(hsvImage, threshImage, 0, 100, CV_THRESH_BINARY);
Run Code Online (Sandbox Code Playgroud)

3)使用blob检测库(如cvBlobsLib)丢弃低于最小大小的颜色区域.这将消除场景中相似颜色的点.我是否需要指定原始图像或背景图像?

CBlobResult blobs = CBlobResult(threshImage, NULL, 0);
blobs.Filter( blobs, B_EXCLUDE, CBlobGetArea(), B_LESS, 10);
Run Code Online (Sandbox Code Playgroud)

4)使用cvInRangeS掩盖颜色并使用生成的蒙版应用新色调.

不确定这个函数它如何帮助更换颜色并且无法理解要提供的参数.

5)cv使用新色调对新图像进行处理,图像由在第一步中保存的饱和度和亮度通道组成.

据我所知,cvMerge将合并HS和V的三个通道,但我如何使用上述三个步骤的输出.

所以基本上坚持使用opencv实现,

如果可能的话请指导我进行opencv实现或任何其他试用的解决方案.

iphone opencv core-graphics image-processing quartz-core

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

iOS 7通知中心与标签一样

在iOS7通知中心,标签(和分隔线)有一个非常有趣的背景:模糊图像,以及看起来像柔和的光混合模式.

我不确定要搜索什么.关于如何做到这一点的指针将非常感激.

直到现在,我已经尝试通过将模糊图像的一部分设置为背景来复制效果label.textColor = [UIColor colorWithPatternImage:...].这也没有考虑背景全黑(或白色)的情况,并导致文本变得不可读.

但这似乎并不合适.

像这样:

模糊的例子

这是我尝试过的:

- (void)viewDidLoad
{
    [super viewDidLoad];

    const CGFloat fontSize = 25.f;
    const NSString *text = @"A long-ish string";
    CGSize size = [text sizeWithAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"Avenir Next" size:fontSize]}];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(80, 270, size.width, size.height)];
    label.font = [UIFont fontWithName:@"Avenir Next" size:fontSize];
    label.textAlignment = NSTextAlignmentNatural;
    label.backgroundColor = [UIColor clearColor];
    label.text = text;

    UIImage *image = [UIImage imageNamed:@"wat@2x"];
    UIImage *blurredImage = [image applyBlurWithRadius:20.5 tintColor:[UIColor clearColor] saturationDeltaFactor:1.f maskImage:nil];

    UIImageView *imageView = [[UIImageView …
Run Code Online (Sandbox Code Playgroud)

objective-c ios quartz-core

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