![](/img/trans.png)
[英]How do I create/render a UIImage from a 3D transformed UIImageView?
[英]How can i create a UIImage from a UIImageView?
我正在嘗試在我的應用程序上實現一組動畫圖像。
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.gif"],
nil];
UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 0.25; // seconds
myAnimatedView.animationRepeatCount = 0; // 0 = loops forever
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[myAnimatedView release];
好的,但是問題是我正在使用API函數在地圖上放置標記。
該功能如下:
RMMarker *newMarker;
UIImage *blueMarkerImage = [UIImage imageNamed:@"marker.png"];
newMarker = [[RMMarker alloc] initWithUIImage:blueMarkerImage anchorPoint:CGPointMake(0.5, 1.0)];
[mapView.contents.markerManager addMarker:newMarker AtLatLong:position];
[newMarker release];
問題是“ initWithUIImage:”僅適用於UIImage,不適用於UIImageView。
那么,我該如何解決呢?
更新:我的新代碼不起作用:
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"marker0.png"],
[UIImage imageNamed:@"marker1.png"],
[UIImage imageNamed:@"marker2.png"],
[UIImage imageNamed:@"marker3.png"],
[UIImage imageNamed:@"marker4.png"],
nil];
UIImageView *myAnimatedView = [UIImageView alloc];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 10; // seconds
myAnimatedView.animationRepeatCount = 1; // 0 = loops forever
[myAnimatedView startAnimating];
RMMarker *newMarker = [[RMMarker alloc] initWithUIImage:[myAnimatedView image] anchorPoint:CGPointMake(0.5, 1.0)];
[mapView.contents.markerManager addMarker:newMarker AtLatLong:markerPosition];
您可以嘗試使用來自UIImageView
image
消息:
newMarker =
[
[RMMarker alloc]
initWithUIImage:[myAnimatedView image]
anchorPoint:CGPointMake(0.5, 1.0)
];
或者,如果您需要創建UIImageView
則可以嘗試:
UIImageView *newMakerImageView =
[[UIImageView alloc] initWithImage:
[
[RMMarker alloc]
initWithUIImage:yourImageHere
anchorPoint:CGPointMake(0.5, 1.0)
]
];
UIImageView *myAnimatedView = [UIImageView alloc]
那可能只是復制/粘貼錯誤,但是您忘記了init。
UIImageView *myAnimatedView = [[[UIImageView alloc] initWithFrame:[self bounds]] autorelease]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.