小编Pre*_*van的帖子

如何在动画CABasicAnimation时改变速度

在我的应用程序中,我使用CABasicAnimation进行动画制作.我想动态更改动画的速度,所以我添加了一个滑块来改变速度.以下是我的动画代码.但是我无法改变速度,当我改变速度值时没有任何反应.

        CABasicAnimation * a = [CABasicAnimation animationWithKeyPath:@"position"];
    [a setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];

    CGPoint startPt = CGPointMake(self.view.bounds.size.width + displayLabel.bounds.size.width / 2,
                                  displayLabel.frame.origin.y);
    CGPoint endPt = CGPointMake(displayLabel.bounds.size.width / -2, displayLabel.frame.origin.y);

    [a setFromValue:[NSValue valueWithCGPoint:startPt]];
    [a setToValue:[NSValue valueWithCGPoint:endPt]];
    [a setAutoreverses:NO];
    [a setDuration:speeds];
    [a setRepeatCount:HUGE_VAL];
    [displayLabel.layer addAnimation:a forKey:@"rotationAnimation"];


    - (IBAction)speedSlider:(id)sender {

         speeds = slider.value;

   }
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c cabasicanimation ipad ios

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

NSUndoManager 使用旋转手势撤消 UIImage 旋转

如何使用旋转手势NSUndoManager来旋转UIImageView?这是我的旋转代码。

- (void)handleRotate:(UIRotationGestureRecognizer *)recognizer 
{
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        prevRotation = 0.0;
    } 

    float thisRotate = recognizer.rotation - prevRotation;
    prevRotation = recognizer.rotation;
    recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, thisRotate);

    CGPoint lastpoint = point;
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uiimageview uigesturerecognizer ios

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

比较iOS中的两个频谱图

我正在使用apple提供的示例代码aurio touch绘制光谱图.现在我想比较iOS中的两个频谱图,看它们是否相同.是否可以使用Accelerate框架比较两个光谱图?

如果有可能,有人知道如何比较两个光谱图吗?如果没有,是否有任何其他算法或库可以在iOS中用于比较频谱图?

signal-processing objective-c spectrogram ios accelerate-framework

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

应用更新通知的文档

是否有任何文档说当Appstore上的应用程序更新时,Appstore本身会向用户发送有关更新的推送通知?

app-store apple-push-notifications ios

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

UIBezierPath的橡皮擦

我正在使用UIBezierPath在iPad应用程序中进行免费手绘.我想为这个UIBezierPath应用橡皮擦.但我想只通过这条路径擦除绘图.我不能使用路径颜色作为背景颜色,因为我在背景上有其他元素.有谁能够帮我.以下是我的免费手绘图代码.

     - (id)initWithFrame:(CGRect)frame
{

self = [super initWithFrame:frame];

if (self) {

    self.backgroundColor = [UIColor clearColor];

    self.opaque = NO;

    lineWidths = 10;

    brushPattern = [UIColor greenColor]; 

    pathArray = [[NSMutableArray alloc]init];

    bufferArray = [[NSMutableArray alloc]init];

    self.multipleTouchEnabled = NO;

}

return self;
}

- (void)drawRect:(CGRect)rect

 {

for (NSMutableDictionary *dictionary in pathArray) {

    UIBezierPath *_path = [dictionary objectForKey:@"Path"];

    UIColor *_colors = [dictionary objectForKey:@"Colors"];

    [_colors setStroke];

    _path.lineCapStyle = kCGLineCapRound;

    [_path stroke];


   }  

}

  -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
   {

myPath=[[UIBezierPath alloc]init];

myPath.lineWidth=lineWidths;

CGPoint touchPoint = [[touches …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ipad ios uibezierpath

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

每天下午5点重复UILocalNotification

如何在每天下午5点重复UILocalNotification?以下是我设置自定义时间的代码.但我想每天通过自定义通知用户,或者可能是静态时间.我正在使用iOS 6.

    -(void)scheduleNotification{

 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
 [dateFormatter setDateFormat:@"h:mm a"];
NSDate *dateFromString = [[NSDate alloc] init];

dateFromString = [dateFormatter dateFromString:timeStr];

UILocalNotification *localNotif = [[UILocalNotification alloc] init];

if (localNotif == nil)
    return;


localNotif.fireDate = dateFromString;

localNotif.repeatInterval = kCFCalendarUnitDay;
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody = @"Reminder is set";
// Set the action button
localNotif.alertAction = @"Ok";

localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;

// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Local Push received while …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c ios uilocalnotification

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

在uitextview周围添加自定义边框但很少超出其范围

如何在uitextview上添加边界,超出其范围.我可以给边界的位置或我必须添加自定义边框并给它的位置.任何帮助将不胜感激.

iphone objective-c uitextview ipad ios

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

在UIImageView上绘制UIBezierPath

怎样绘制UIBezierPathUIImageView?我尝试过以下代码,但是当UIImageView's图像出现时,nil我只能看到路径,当我添加图像时,此路径与UIImageView's图像重叠.我想绘制UIImageVIew's图像上方的路径.

cocoa-touch objective-c uiimageview ios uibezierpath

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

UIImageView在触摸方向上旋转动画

我有一个UIImageView有一个箭头的图像.当用户点击UIView时,此箭头应指向水龙头维持其位置的方向,它应该只是改变变换.我已经实现了以下代码.但它没有按预期工作.我添加了截图.在此屏幕截图中,当我触摸左上角时,箭头方向应该如图所示.但是没有发生这种情况.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

 UITouch *touch=[[event allTouches]anyObject];
 touchedPoint= [touch locationInView:touch.view];
 imageViews.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(rangle11));
 previousTouchedPoint = touchedPoint ;
}

- (CGFloat) pointPairToBearingDegrees:(CGPoint)startingPoint secondPoint:(CGPoint) endingPoint
{

 CGPoint originPoint = CGPointMake(endingPoint.x - startingPoint.x, endingPoint.y - startingPoint.y); // get origin point to origin by subtracting end from start
   float bearingRadians = atan2f(originPoint.y, originPoint.x); // get bearing in radians
float bearingDegrees = bearingRadians * (180.0 / M_PI); // convert to degrees
bearingDegrees = (bearingDegrees > 0.0 ? bearingDegrees : (360.0 + bearingDegrees)); // correct …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch transform image-rotation uiimageview ios

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

CGContext绘制图像

我正在使用CGContext在UIImageView上绘制自由的手线.但是当我使用时

UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
Run Code Online (Sandbox Code Playgroud)

使用imageView的大小在Imageview中绘制图像,以便将原始图像大小调整为imageView的大小.而且我必须将图像大小调整为原始大小,同时这样做会失去其质量.如何在imageView上直接在图像上绘图?此外,我必须使用imageview来适应视图中的图像,以便我可以在其上绘制线条.请帮忙 !!!

iphone cocoa-touch objective-c cgcontext ios

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