Tag: uiview

UIViewanimation跳过第一个animation

对这个抱歉很新! 一旦我运行按button“按”UIView“背景”的背景颜色立即改变为蓝色,然后animation到紫色,完全跳过animation黄色,然后到蓝色。 我做错了什么? @IBAction func Press(sender: AnyObject) { UIView.animateWithDuration(5, animations: { self.Background.backgroundColor = UIColor.yellowColor() self.Background.backgroundColor = UIColor.blueColor() self.Background.backgroundColor = UIColor.purpleColor() }, completion:{(Bool) in println("COLOR CHANGED") }) }

我有一个UILabel自动布局定位在屏幕上,但是当我隐藏导航栏,它会导致标签“抽搐”第二个

项目: http : //cl.ly/1T2K0V3w1P21 通过这个项目可以看出,这只是一个简单的下载,仅仅是视图控制器。 基本上,我的UILabel与自动布局保持完美的地方,但是当我隐藏导航栏(你可以通过在任何地方点击屏幕在项目中做到这一点),导致它抽搐。 不pipe导航栏上发生了什么,我如何使它保持在完全相同的位置? 它似乎是animation(我想)导致AutoLayout感到困惑。 以下是标签上的限制条件: 任何人都可以提供一些build议,我做错了什么?

试图一次执行多个animation

似乎很奇怪,我无法在networking上find任何答案,但似乎如果你想以不同的速度同时移动6个UIViews ,你不能这样做。 如果我使用这个例子中的一个,那么我得到的结论是,有时候只有一部分视图正在移动,有时甚至全部移动(如预期的那样)。 无法同时移动6-7-8个UIViews, 持续 时间 不同 ? 1。 for(UIButton *button in buttons) { float r= arc4random()%10; float t =0.1+ 1.0/r; [UIView beginAnimations:@"Anim0" context:nil]; [UIView setAnimationDuration:t]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:button cache:YES]; CGRect newframe=button.frame; newframe.origin.y=0; button.frame=newframe; [UIView commitAnimations]; } 2。 for(UIButton *button in buttons) { int random=arc4random()%10; float time=0.5+ 1/(float)random; CGRect newframe=button.frame; newframe.origin.y=0; [UIView transitionWithView:button […]

当UISlider离开时获得负值

我试图找出如何得到滑块的负值,当它回来。 当我从左向右滑动时,它返回一个正值。 当它返回时(从右到左),我需要它返回一个负值。 换句话说,我怎么能检测到滑块回来? self.borderSlider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 200, 30)]; self.borderSlider.center = CGPointMake(self.view.centerX, SCREEN_WIDTH / 2); self.borderSlider.minimumValue = 0.0f; self.borderSlider.maximumValue = 100.0f; self.borderSlider.tintColor = [UIColor grayColor]; [self.borderSlider addTarget:self action:@selector(borderSliderValueChanged:) forControlEvents:UIControlEventValueChanged];

如何获取实例variables名称?

我用下面的编程方式创build了一个带有两个UIButton的简单的iPhone屏幕。 – (void)viewDidLoad { [super viewDidLoad]; UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeRoundedRect]; buttonOne.frame = CGRectMake(60, 70, 200, 40); [buttonOne setTitle:@"One" forState:UIControlStateNormal]; [self.view addSubview:buttonOne]; UIButton *buttonTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; buttonTwo.frame = CGRectMake(60, 250, 200, 40); [buttonTwo setTitle:@"Two" forState:UIControlStateNormal]; [self.view addSubview:buttonTwo]; } 现在按下标题为“One”的button,我想把variables名称命名为“buttonOne”,同样按下标题为“Two”的button,我想把variables名称命名为“buttonTwo”。 我没有find一个方法来获取variables名称。 任何帮助? 提前致谢

需要更改CALayer类对象的大小和位置

我试图复制苹果提供的这个示例应用程序的所有function称为AVCam: https : //developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid / DTS40010112-简介-DontLinkElementID_2 我唯一遇到的问题是更改UIView对象的大小和位置。 问题是我正在使用苹果的示例代码,这只是对我来说没有意义。 苹果公司提供了这个示例VC,我称之为MediaCapturePreviewView。 这是头文件代码: #import <UIKit/UIKit.h> @class AVCaptureSession; @interface MediaCapturePreviewView : UIView @property (nonatomic) AVCaptureSession *session; @end 这是它的主要文件代码: #import "MediaCapturePreviewView.h" #import <AVFoundation/AVFoundation.h> @implementation MediaCapturePreviewView – (void)drawRect:(CGRect)rect { // Drawing code } */ + (Class)layerClass { return [AVCaptureVideoPreviewLayer class]; } – (AVCaptureSession *)session { return [(AVCaptureVideoPreviewLayer *)[self layer] session]; } […]

如何创build纵向和横向布局的UIView

我正在尝试创build一个UIView,它既适用于纵向模式,也适用于横向模式,但不知道如何实现这一点。 仅供参考 – 我通过代码铺设所有组件,所以没有XIB或故事板…这是一个要求。 我有一个名为createView的方法,它列出了任何时候创build视图的所有视图组件(button,标签等等)。 我不知道的是说我的控制器通过addSubview:myNewCustomView在水平模式下添加视图,那么当从纵向切换到横向时,如何更改自定义UIView中组件的布局? 我会创build自定义UIView中的方法来布局肖像和另一个景观? 如果我有两个方法,我将不得不父母显示模式,风景或肖像,然后在我的自定义UIView调用适当的createView方法?

如何在iOS中使用animation概念将一个UIview推送到另一个UIview

嗨,我是非常初学者在iOS和我的项目中,我已经在我的主UIViewController上编程添加了两个UIViews ,在这里我的主要要求是当我点击“下一步”button,在我的firstView ,我想推FirstView到SecondView ,点击“返回”button哪里有在SecondView我想pushBack secondView到firstView就像如何推一个UIViewController到另一个UIViewController 但同样的要求,我想要以编程方式使用UIView请帮我我们如何做到这一点 我的代码: – #import "ViewController.h" @interface ViewController () { UIView * FisrtView; UIView * SecondView; UIButton * Next; UIButton * Back; } @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; FisrtView = [[UIView alloc] init]; FisrtView.backgroundColor=[UIColor lightGrayColor]; FisrtView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:FisrtView]; SecondView = [[UIView alloc] init]; SecondView.backgroundColor=[UIColor orangeColor]; SecondView.translatesAutoresizingMaskIntoConstraints […]

UIPageViewController-PDF缩放不工作的Xcode?

我正在使用下面的github项目 https://github.com/jackhumphries/UIPageViewController-PDF 问题是PDF正在加载和页面curl效果工作,但我不能放大和缩小我的PDF文件加载我尝试debugging以及为什么它不工作,但我找不到解决scheme,我检查了PDFScrollView委托方法,他们都实现了,但是当我试图放大/缩小时,这些方法并没有调用。 这里是这些方法: – (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.tiledPDFView; } – (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view { // Remove back tiled view. [self.oldTiledPDFView removeFromSuperview]; // Set the current TiledPDFView to be the old view. self.oldTiledPDFView = self.tiledPDFView; [self addSubview:self.oldTiledPDFView]; } – (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { // Set the new scale factor for […]

UIView animateWithDuration在iOS 8中performance有所不同

我刚刚从iOS 7.1切换到了iOS 8.1。 我遇到以下UIView animateWithDuration问题。 图片胜过千言万语,我制作了每个iOS下的行为video: iOS 7.1: iOS 8.1: 这是一个iPhone应用程序。 我应该注意到,在发布之前,我已经search了SO和其他地方。 这似乎是一个公认的问题,但是我发现有一些“使用基于约束的animation”(我不明白),closures了自动布局,但没有真正的共识。 我尝试了几次刺,但没有得到。 如果有人能指出我(或通过一个明确的解决办法),我真的很感激。 我应该提到的是,应用程序的目的只是在肖像位置,所以我没有想到在开发过程中的自动布局。 所有涉及的视图都是以编程方式创build的,除了滚动条本身。 这是代码。 我包括了很长的整个方法,但是我真的不明白在新的iOS中已经发生了什么变化,所以在安全方面。 animateWithDuration调用非常深入到块中: -(void) displayDayChart { [self.scroller setBackgroundColor:[UIColor clearColor]]; UIImage *image = [UIImage imageNamed:@"GrayPaper.png"]; self.chartView.backgroundColor = [UIColor colorWithPatternImage:image]; [self.view addSubview:self.scroller]; [self.scroller setScrollEnabled:YES]; [self.scroller setContentSize:CGSizeMake(320, 1800)]; [self.scroller setContentOffset:CGPointMake(0.0, 0.0) animated:YES]; dayBarArray = [[NSMutableArray alloc]init]; infoLabelArray = [[NSMutableArray alloc]init]; timeLabelArray […]