Tag: uiimageview

在UIImageView中加载animation的图像 – iOS

我有大约300个图像加载animation图像被命名为loading001.png, loading002.png, loading003.png, loading004.png………loading300.png 我正在这样做。 .h文件 #import <UIKit/UIKit.h> @interface CenterViewController : UIViewController { UIImageView *imgView; } @end .m文件 @implementation CenterViewController – (void)viewDidLoad { [super viewDidLoad]; imgView = [[UIImageView alloc] init]; imgView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"loading001.png"], [UIImage imageNamed:@"loading002.png"], [UIImage imageNamed:@"loading003.png"], [UIImage imageNamed:@"loading004.png"], nil]; } – (IBAction)startAnimation:(id)sender{ [imgView startAnimating]; } @end 有没有一种有效的方法来将图像加载到数组中。 我曾尝试过for loop但无法弄清楚。

如何让我的精灵套件场景出现在UIView上方?

我已经做了一些search,但没有find任何直接解决我的问题:我有一个SKScene与几个SKNodes每个SKSpriteNode对象为我的游戏,我使用的背景UIImageView (有一些事情,我需要做的背景至less在我看来,这不可能合理地用sprite工具包来完成)。 我遇到的问题是UIImageView出现在一切之上,我看不到我的游戏对象。 在我的视图控制器(.m文件)我有以下代码来调用我的场景 @implementation GameViewController – (void)viewDidLoad { [super viewDidLoad]; SKView * skView = (SKView *)self.view; SKScene * scene = [GameScene sceneWithSize:skView.bounds.size]; scene.scaleMode = SKSceneScaleModeAspectFill; [skView presentScene:scene]; } 在上面的GameScene ,我有几个SKNodes ,其中我所有的游戏对象都是子nodeHDU (例如nodeHDU , nodePlay , nodePauseMenu …),我使用UIImageView作为背景(我在背景场景之间切换,使用一些不错的转换,如UIViewAnimationOptionTransitionCrossDissolve;不能使用SKSpriteNode作为背景来实现这一点,而不使用多个SKSpriteNodes和一个复杂的SKActions数组,所以我使用UIImageView ) UIView *backgrounds = [[UIView alloc] init]; [self.view insertSubview:backgrounds belowSubview:self.view]; UIImageView *imageBackground = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)]; [backgrounds […]

确定哪一个UIImageView显示的animationImages?

有没有办法找出它的animationUIImage是哪一帧? 当你启动它时,你给它一个animationImages数组,所以显然必须存储当前图像的索引。 你知道我怎么能find这个? 另外,有没有办法告诉UIImageView哪个框架开始animation?

如何创build具有全屏图像ios的自定义UIImagePickerController

我有一个简单的UIImagePickerController,它将使用相机来拍照,但有一些事情,我希望它做的: 有一个自定义相机用户界面 采取全屏而不是480×640(如果在4英寸的电话) 这里是我的代码显示UIImagePickerController: – (IBAction)pick:(id)sender { NSLog(@"abc"); picker = [[UIImagePickerController alloc] init]; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { [picker setSourceType:UIImagePickerControllerSourceTypeCamera]; } else { [picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; } [picker setDelegate:self]; [self presentViewController:picker animated:YES completion:nil]; } 这是为什么当图像被采取: – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissViewControllerAnimated:YES completion:nil]; UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; [imageView setImage:image]; } 我该怎么做呢? 谢谢

如何使用

我想拉伸尺寸为170×50的图像,并在尺寸为240×140的图像视图中显示。 原始图像看起来像: 我想保持四个angular落,只有拉伸中心部分。 我使用下面的代码: UIImage *originalImg = [UIImage imageNamed:@"ImageNamed"]; UIImage *resizeImg = [originalImg resizableImageWithCapInsets:UIEdgeInsetsMake(20 ,10, 10, 10)]; self.originalImgV.image = originalImg; self.resizedImgV.image = resizeImg; originalImgV和resizedImgV都设置为“纵横填充”。 我在模拟器上运行它,结果是: 我无法理解的是:resizedImgV有2个箭头! 任何人都可以告诉我为什么,如何正确使用它? 谢谢

如何左alignmentUISearchBar占位符文本

我需要做一个像这样的自定义search栏。 我遇到的问题是左alignment占位符文本,以及将search图标放在右侧。 我有一个试图在UIImageView使用的search图标的PNG,并将UIImageView设置为UISearchBar的UITextField的rightView UITextField 。 这个解决scheme还没有奏效,我用完了想法。 有没有人有办法解决吗?

iOS:TapGestureRecognizer问题

所以我有一个应用程序,就像一个照片库,我正在实现用户删除图像的能力。 这里是设置:我有9 UIImageViews,imageView,imageView2等。我也有一个“编辑”button,tapGesture行动方法。 我将一个Tap Gesture识别器拖到IB的视图中,并将其附加到每个UIImageView。 我还将tapGesture操作方法附加到每个UIImageView。 理想情况下,我希望方法只有在按下“编辑”button时才能激活。 当用户点击编辑,然后点击他们想要删除的图片,我想要一个UIAlertView出现,问他们是否确定要删除它。 这是我正在使用的代码: – (IBAction)editButtonPressed:(id)sender { editButton.hidden = YES; backToGalleryButton.hidden = NO; tapToDeleteLabel.hidden = NO; } – (IBAction)tapGesture:(UITapGestureRecognizer*)gesture { UIAlertView *deleteAlertView = [[UIAlertView alloc] initWithTitle:@"Delete" message:@"Are you sure you want to delete this photo?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [deleteAlertView show]; if (buttonIndex != [alertView cancelButtonIndex]) { UIImageView *view = […]

UIImageView自动resize

我想设置一个图像到UITableView的SimpleTableCell的UIImageView 。 我已经改变了imageview的大小,但每当我尝试设置图像,它会自动调整自己。 我试图使用这里的代码来调整图像的大小,并设置它。 但它只适用于将图像尺寸设置为(20×20),这是UIImageView (40×40)大小的一半。 所以变得模糊了。 我也尝试设置UIAspectRatioFit/UIAspectratioFill和clipsToBounds = YES 。 似乎没有任何工作。 另一个奇怪的部分是,当我使用从web直接下载的图像时, imageView不会自动resize,如下所示: – (void)connectionDidFinishLoading:(NSURLConnection *)connection { UIImage *userImage = [UIImage imageWithData:userImageData scale:self.profileImage.frame.size.height/self.profileImage.frame.size.width]; UITableViewCell *cell = [self.myTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; cell.imageView.image = userImage; } 但是,然后我把这个图像存储到文档目录,然后尝试重新加载在其他地方,resize发生。 任何解决scheme

uiimageview中的animation图像

如何从Web服务animation图像。 我得到的代码来从bundle中animation化图像。如何从url数组加载图像 该代码附在下面 UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; animatedImageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"image1.gif"], [UIImage imageNamed:@"image2.gif"], [UIImage imageNamed:@"image3.gif"], [UIImage imageNamed:@"image4.gif"], nil]; animatedImageView.animationDuration = 1.0f; animatedImageView.animationRepeatCount = 0; [animatedImageView startAnimating]; [self.view addSubview: animatedImageView];

我如何同时animationUIImageView的图像和UIImageView本身?

标题可能不是那么清楚,但我想要做的是让UIImageView显示一系列图像(有点像GIF),我通过设置animationImages到一个图像数组,然后调用[imageView startAnimating]; 。 这工作正常。 我也有移动UIImageView的CABasicAnimation的代码,这个animation代码也可以正常工作。 但是,当我尝试为UIImageView的图像设置animation并尝试移动UIImageView时,UIImageView的图像停止animation。 有没有解决方法? 这里是我的animationUIImageView的内容的代码: self.playerSprite = [[UIImageView alloc] initWithImage:[self.player.animationImages objectAtIndex:0]]; [self.playerSprite setFrame:CGRectMake(self.center.x, self.center.y, self.tileSet.constants.TILE_WIDTH, self.tileSet.constants.TILE_HEIGHT)]; self.playerSprite.animationImages = self.player.animationImages; self.playerSprite.animationDuration = self.tileSet.constants.animationDuration; self.playerSprite.animationRepeatCount = 0; //Makes it repeat indefinitely 这里是我用CABasicAnimationanimationUIImageView的编码: float playerSpriteX = self.playerSprite.center.x; float playerSpriteY = self.playerSprite.center.y; CABasicAnimation *moveAnimation = [CABasicAnimation animation]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(playerSpriteX + TILE_WIDTH, playerSpriteY)]; [moveAnimation setDelegate:self]; […]