English 中文(简体)
- 轮值 根据X,Y方向提出的观点
原标题:iOS - rotating an UIImageView based on X,Y orientation

I ve sub UIView as a avatar-object, which contained an icon (UIImageView), name (UILabel) and ID (UILabel). 根据方向X,Y坐标,我想轮到会。 例如,指方向。 X = 1和取向。 Y = 1可分45度。 X和Y可能在-1至1之间有任何区别。

我不敢确定如何用数学计算,也不需要可可豆。 有什么想法可以开始?

最佳回答

for for

- (void)rotateView:(UIView *)view withDuration:(NSTimeInterval)duration andRadians:(CGFloat)radians
{
    // Setup the animation
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [UIView setAnimationBeginsFromCurrentState:YES];

    // The transform matrix
    CGAffineTransform transform = CGAffineTransformMakeRotation(radians);
    view.transform = transform;

    // Commit the changes
    [UIView commitAnimations];

}

EDIT:

for other angles you need to create your own rotation matrix.

轮值如何运作

Read here how to create a custom affine transformation in Objective-c

Hope this helps.

问题回答

你们需要看三管功能——特别是<条码>/条码>和<条码>。

本条可有所帮助。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签