Tag: uiview

使用UIVisualEffectView创build一个模糊视图,在模拟器上正确,但不是在iPhone和iPad上

目标:在应用程序中创build模糊视图。 我使用的代码是: func createBlurBackgroundView() { if !UIAccessibilityIsReduceTransparencyEnabled() { if blurredSubView == nil || blurredSubView.superview == nil { print("Create blurred background view") self.backgroundColor = UIColor.clearColor() let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light) blurredSubView = UIVisualEffectView(effect: blurEffect) blurredSubView.frame = self.bounds self.insertSubview(blurredSubView, atIndex: 0) } } else { print("Transparency disabled!! no blur view") } } 结果是:在模拟器上的一切工作正常: 但是当我在iphone和ipad上运行它时,它看起来像: 请注意我没有改变“降低透明度”的设置! 那么当我想拍摄这个黑色的背景而不模糊的时候,你猜怎么着? 在照片stream中,我看到了正确的模糊视图图片… […]

在后台线程上构buildUIViews

我知道UI只应该在主线程上更新,但是可以在单独的线程上创build和添加子视图,只要它们不被添加到可见视图中。 会造成内存和性能问题吗? 这是一些示例代码。 NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [queue addOperationWithBlock:^{ // do some fancy calculations, building views UIView *aView = .. for (int i, i<1000, i++) { UIView *subView = … [aView addSubview:subView]; } // Update UI on Main Thread [queue addOperationWithBlock:^{ [[NSOperationQueue mainQueue] addOperationWithBlock:^{ // Update the interface [self.view addSubview:aView]; }]; }]; }];

如何显示UIView的键盘

我有一个UIView,我想要接收键盘input。 我努力了: [self becomeFirstResponder]; 但它不起作用。 我可以通过隐藏的UITextField实现一个“脏”的解决方法,并将关键字转发到我的UIView – 但是我的UIView如何直接接收键盘input?

带有透明UIImageView的页面curlanimation(iOS)

我有一个丝带(书签),我想蜷缩起来,离开屏幕。 function区的底部有一个V形切口,这是一个透明的部分 – 一个带有透明png的UIImageView。 当我在function区上执行curl时,底层阴影代表整个视图(这在技术上是正方形的)。 我试图让这个看起来尽可能真实,所以如果有人能指出我的方向是正确的,那将是有帮助的。 我已经尝试 – 掩盖视图 – 调整开源页面curl框架 – 在页面curl期间replaceviewAtIndex – UIViewanimation 但他们都造成了一个正方形的影子。 目前为止我可以提供的最好的体验是一个简单的UIViewanimation,而淡出的: [UIView transitionWithView:_ribbonButton duration:0.5f options:UIViewAnimationOptionTransitionCurlUp animations:^{ [_ribbonButton setAlpha:0.0f]; } completion:^(BOOL completed){ [self animationCompleted:completed]; }]; 这是一个截图: http : //livevision.us/wordpress/?attachment_id=60

在layoutSubviews中调用setNeedsDisplay?

考虑在drawRect:绘制自定义背景的视图drawRect: 如果视图更改大小,则需要重绘背景。 这是一个坏主意吗? – (void) layoutSubviews { [super layoutSubviews]; [self setNeedsDisplay]; } 如果是这样,考虑到我无法控制谁改变了视图的大小,那么更好的select是什么?

使用Yalantis / Koloda库加载不止1个UIView

所以我正在使用这个库,并且在提供的例子中,只有静态图像被用来加载到每个卡。 但是我想定制每张卡的外观和感觉,标签,多重UImages等,我将加载从parse.com。 我怎样才能做到这一点。 函数func kolodaViewForCardAtIndex(koloda:KolodaView,index:UInt) – > UIView { } 只返回UIview。 有什么build议么。

UILabel sizeThatFits不起作用

我试图计算一个UITableViewCell的高度,所以我定义了一个类似这样的方法 + (CGFloat)heightWithText:(NSString *)text { SizingLabel.text = text; [SizingLabel sizeThatFits:CGSizeMake(LABEL_WIDTH, CGFLOAT_MAX)]; return (TOP_MARGIN + SizingLabel.frame.size.height + BOTTOM_MARGIN); } 我已经这样定义了SizingLabel: + (void)initialize { SizingLabel = [[UILabel alloc] initWithFrame:CGRectZero]; SizingLabel.numberOfLines = 0; SizingLabel.lineBreakMode = NSLineBreakByWordWrapping; } 但是,如果我在-heightWithText:方法中插入断点,我注意到SizingLabel的尺寸永远不会改变,因此我得到一个不正确的值。 这是为什么?

SIGABRT消息仅适用于iOS5

我正面临我的应用程序的一个奇怪的崩溃,只发生在iOS5。 这个问题似乎与我的核心animation方法bellow,因为当我没有设置值为aAnimation.repeatCount或0它正在工作,但是当它旋转我使用得到SIGABRT消息错误: – [NSConcreteValue doubleValue]:无法识别的select器发送实例0x9628100当我触摸设备/模拟器屏幕。 任何帮助将不胜感激 我的观点定义 – (void)loadView { CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; UIView * contentView = [[UIView alloc] initWithFrame:screenRect]; contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.view = contentView; [contentView发布]; } 设置一个子视图 – (void)setUpPlacardView:(NSInteger)picture { //创build标牌视图 – 其init方法根据图像计算其框架 PlacardView * aPlacardView = [[PlacardView alloc] init:picture asColor:asColor]; aPlacardView.desaturation = kotucHue; self.placardView = aPlacardView; [aPlacardView发布]; […]

调用loadView明确 – 好/坏?

显式调用loadView有没有什么坏处? 我必须点击服务器并获取要显示的数据,并根据此视图上的某些用户操作更改此数据。 我正在我的loadView方法中的服务器调用,并传递适当的参数。 现在,当用户条件发生变化时,我调用[self loadView]修改参数。 你在这里看到一些问题吗?

UIView对象中的UIGestureRecognizer

我创build了一个UIViewController ,其中包含一个UIView对象。 我希望UIView对象响应一个手指的一个水龙头,还捏两个手指。 我已经点击xib中的“用户交互启用”和“多点触摸”选项。 我在UIView函数initWithFrame:中创build了UITapGestureRecognizer和UIPinchGestureRecognizer ,因为它是UIView对象的唯一入口点。 但该对象不响应UIGestureRecognizer对象。 为什么? 或者,放置UIGestureRecognizer对象的最佳位置在哪里? – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code // single tap UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; singleTap.numberOfTapsRequired = 1; singleTap.numberOfTouchesRequired = 1; [self addGestureRecognizer: singleTap]; // 2 fingers pinch UIPinchGestureRecognizer* doubleMove = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleMove:)]; [self addGestureRecognizer: doubleMove]; […]