Tag: uiimageview

如何在UIimageView中设置顶部避免空间的图像

我有一个UIImageView与内容模式大小为220×155的方面适合。 我以不同的分辨率dynamic插入不同的图像,但都大于UIImageView的大小。 由于内容模式设置为Aspect Fit,图像将根据比例进行缩放以适合UIImageView。 我的问题是,如果例如在UIImageView内的图像缩放到220×100,我想UIImageView从155高度缩小到100以避免我的元素之间的空间。 我怎样才能做到这一点?

收集查看重复单元格时加载更多的数据

问题: 我有一个CollectionView,它将UIimage加载到每个单元格中。 然而,我的问题是,当我加载更多的图像他们似乎重复其他单元格。 我不太明白在我的代码中可能会造成这种情况。 可能是因为可重复使用的单元存在一些问题? 任何人都可以看到为什么会发生? 注意:与图像的数组不重复 问题video: https : //www.youtube.com/watch?v = vjRsFc8DDmI 问题的形象: 这里是我的函数为collectionView: func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { //#warning Incomplete method implementation — Return the number of items in the section if self.movies == nil { return 0 } return self.movies!.count } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> […]

UITapGestureRecognizer不在UIImageView中工作

我有以下代码: UITapGestureRecognizer *showStoryTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showNewsStory:)]; [showStoryTapRecognizer setDelegate:self]; [self.storyImageView_ addGestureRecognizer:showStoryTapRecognizer]; [showStoryTapRecognizer release]; 但是这并不会触发showNewsStory,为什么呢? 我已经在图像视图中启用了userInteraction。

如何通过MPMoviePlayerController |添加UIImageView iOS | 目标C

我有一个使用MPMoviePlayerController显示video的控制器。 我需要在video上放置一个图片。 我想用下面的代码,但它不显示。 我错过了什么? // method to play the video – (void)playVideoInLoopMode:(BOOL)loop { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"myvideo" ofType:@"m4v"]]; MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url]; mp.controlStyle = MPMovieControlStyleNone; if (loop) { mp.repeatMode = MPMovieRepeatModeOne; } mp.view.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height); self.player = mp; [self.view addSubview:self.player.view]; [self.player prepareToPlay]; [self.player play]; } // method […]

防止出现在UIPageViewController上的白色空白

我已经以这种方式实现了UIPageViewController: GalleryViewController :是PageViewController的容器 PageViewController :是我把它作为子视图添加到GalleryViewController的pageViewController。 PageContentViewController :我把UIImageView作为页面视图控制器的内容。 一切都很顺利,但当我在图像之间滑动时,会发生奇怪的事情。 上方出现白色的空白。 奇怪的是当我完成滚动它自动延伸。 这是GalleryViewController的代码,它是PageViewController的容器: import UIKit class PageViewController: UIViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate { var startIndex:Int = 0 var pageViewController : UIPageViewController! override func viewDidLoad() { self.navigationController?.hidesBarsOnTap = true; reset() } func reset() { /* Getting the page View controller */ pageViewController = self.storyboard?.instantiateViewControllerWithIdentifier("PageViewController") as UIPageViewController self.pageViewController.dataSource = self let […]

Imageview ios中的遮罩和反向遮罩

我有一个Imageview包含图像。 和一个包含兔子形状的面具形状。 我有一个代码给出了下面的结果。 – (UIImage*)mynewmaskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGImageRef maskImageRef = [maskImage CGImage]; // create a bitmap graphics context the size of the image CGContextRef mainViewContentContext = CGBitmapContextCreate (NULL,320, 380, 8, 0, colorSpace,(CGBitmapInfo) kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpace); if (mainViewContentContext==NULL) return NULL; CGFloat ratio = 0; ratio = 320/ image.size.width; if(ratio * image.size.height […]

使用8个图像在UIImageView周围创build一个边框

我有8个图像,每个angular落有4个图像, UIImageView每一边有4个图像。 现在,我怎么让他们“围绕” view使他们形成一个漂亮,可伸缩的边框,像这样(白线是我试图实现的边界): 关于如何基于8个预设图像实现view边框的任何想法? 编辑:我不想画边框,我想用我的8个图像!

将uiimage设置为nil不会释放ARC的内存

我有一个滚动视图,显示不同的图像,像滚动浏览页面,如PhotoScroller。 我正在使用ARC。 当某人滚动到另一个页面时,我将UIImageView的image属性设置为当前不显示为零(试图)以避免内存崩溃,这仍然发生。 然后,当用户滚动到一个新的页面,该页面的图像被设置为UIImageView的图像属性,以及页面前后的页面(用于平滑查看)。 UIImage的页面都保存在一个数组中。 然而,当我滚动浏览页面时,内存使用量不断增加,就像将UIImageView的image属性设置为nil一样,不会从内存中释放它。 我使用initWithContentsOfFile初始化我的UIImages。 我试图用imageNamed和imageWithContentsOfFile也没有运气。 这是我的scrollview代码: – (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { int indexShown = self.scrollView.bounds.origin.x / kScrollObjWidth; for(NSNumber *index in indexesToRemove) { UIImageView *imgViewToRemove = [[self.scrollView subviews] objectAtIndex:[index intValue]]; imgViewToRemove.image = nil; } [indexesToRemove removeAllObjects]; UIImageView *imgViewToReplace = [[self.scrollView subviews] objectAtIndex:indexShown]; [imgViewToReplace setImage:[pageUIImagesArr objectAtIndex:indexShown]]; [indexesToRemove addObject:[NSNumber numberWithInt:indexShown]]; if(indexShown != 0 && ![[[self.scrollView subviews] […]

iOS中的ImageView阴影效果

我正在试图为我的Imageview提供阴影效果,就像在这个图像中一样。 但是我面临的问题是影像实际上是从Imageview的底部可见的。 这是我已经做的添加阴影的代码。 颜色和所有仍然不符合这一个。 CAGradientLayer *shadow = [CAGradientLayer layer]; shadow.frame = CGRectMake(-100, 70, perspectiveView.frame.size.width, perspectiveView.frame.size.height – 20); shadow.startPoint = CGPointMake(1.0, 0.5); shadow.endPoint = CGPointMake(0, 0.5); shadow.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithWhite:0.0 alpha:0.4f] CGColor], (id)[[UIColor clearColor] CGColor], nil]; shadow.opacity = 1.0f; [perspectiveView.layer addSublayer:shadow]; 请提供意见。 另外,如果方法是错误的,请随时引导我到任何其他的方法。 提前致谢。 也有人可以build议如何提供一个3D边框就像在图像提供了一个宽度的图像视图?

IOS:旋转uiimageview

在我的应用程序中,我有一个imageview,它的名字是箭头,我用这种方法旋转180度: arrow.transform = CGAffineTransformMakeRotation(M_PI); 它工作正常,但现在我想这个imageview返回原来的位置; 我应该设置什么价值来获得它?