uikit

Move view with keyboard using Swift

烈酒焚心 提交于 2019-12-16 22:06:34
问题 I have an app that has a text field on the lower half of the view. This means that when I go to type in the text field the keyboard covers the textfield. How would I go about moving the view upwards while typing so I can see what i'm typing and then moving it back down to its original place when the keyboard disappears? I've looked everywhere but all the solutions appear to be in Obj-C which I can't quite convert just yet. Any help would be greatly appreciated. 回答1: Here is a solution,

使用swift在sprite中显示圆角UIButton按钮

*爱你&永不变心* 提交于 2019-12-14 16:35:31
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我对objective-C不是很熟,UIKit以前没有用过,SpriteKit也只看了遍教程,然后看了一遍swift语言教程,此时开始编写这个程序,所以遇到的问题比较小儿科,解决方法也是曲线救国,希望有高人指点解决这些问题的简单方法,有好的解决方法后,我会随时进行本日志的修改,以免误导他人。 程序界面很是简单 然后点击中间的游戏区域,会roll色子,随机产生1~6的数字,飞机前进若干步,遇到梯子向前跳若干步,而遇到蛇则后退若干步,指导抵达25格,游戏结束。 上面有一个标签,显示游戏状态和Roll点值。 下面有一个RESTART按钮,用来重新开始游戏,本日志的关键就是这个按钮。 起先我想法很简单,就是在sprite的scene里边添加一个按钮,但是SpriteKit里边我并没有发现类似按钮控件什么的,开始我使用Label替代按钮的功能,就是在点击事件中判断控件,然后再执行按钮相关代码,这种方法一是按钮太丑,二是点击时没有按钮的动作,三是按钮的方法调用实在是太山寨了。 后来我发现了UIButton,我参考了下面添加按钮的Objective-C代码: CGRect frame = CGRectMake(90, 200, 200, 60); UIButton *someAddButton = [UIButton

A valid image not being returned from CoreImage in MonoTouch for a valid Asset

独自空忆成欢 提交于 2019-12-14 03:59:27
问题 I am trying to get an image using this. img = new UIImage(new MonoTouch.CoreImage.CIImage(validAssetObject),1.0f, UIImageOrientation.Up); A CIImage is returned from the CIImage call. The new UIImage has the CIImage property = null . Seems like the constructor for UIImage is not working as expected? Any ideas from the MonoTouch community? 回答1: I wrote a quick test and this seems to work fine. string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "image.png"); using (var url = NSUrl

How to create rounded image with border and shadow as MKAnnotationView in Swift?

 ̄綄美尐妖づ 提交于 2019-12-14 03:54:00
问题 I'd like to create MKAnnotationView that looks like the one below. The code I already have: func maskRoundedImage(image: UIImage, radius: Float) -> UIImage { let imageView: UIImageView = UIImageView(image: image) var layer: CALayer = CALayer() layer = imageView.layer layer.masksToBounds = true layer.cornerRadius = CGFloat(radius) layer.borderWidth = 4.0 layer.borderColor = UIColor.whiteColor().CGColor UIGraphicsBeginImageContext(imageView.bounds.size) layer.renderInContext

UISlider too sensitive when releasing touch

佐手、 提交于 2019-12-14 02:16:36
问题 When releasing the touch on a UISlider the value of the slider changes slightly and uncontrollably. It's so sensitive that it even changes when just releasing the finger from the screen. How can I achieve that the user can set a value he wants without problems? That's how I create my UISlider: UISlider *slider = [[UISlider alloc] initWithFrame: CGRectMake(100.0, 100.0, 200.0, 40.0)]; slider.minimumValue = 0.0; slider.maximumValue = 100.0; [slider addTarget: self action: @selector

iOS: How to animate a flip between two UIViews?

心不动则不痛 提交于 2019-12-14 00:27:42
问题 I am trying to animate a flip effect between a UIButton instance and a UIImageView instance. Basically it's a "flip over a playing card" effect, one side (UIImageView) is just a nice pattern and when flipped, it should show a UIButton with some text. My code features the following problems: the text of the UIButton sub-view is not shown after flipping the shadow disappears during the flip animation Here's a visual representation of the goal: Here you can download the very simple sample app.

Change UIAlertView size

会有一股神秘感。 提交于 2019-12-13 16:00:32
问题 In my cocos2d game i can't change size of uialertview, i have changed statusbarorientation to landscape, and now want to init alertview with frame, and initwithframe method does not affect the size of alertview, every time the size of alert is the same, is there any way to change it ? 回答1: Here is what i did. Create your uialertview in your controller. then override the following class within your controller (after setting the uialertview delegate ... ie. myalertview.delegate=viewcontroller)

How to force trailing spaces in a right-aligned UITextView?

爱⌒轻易说出口 提交于 2019-12-13 13:12:40
问题 I have a UITextView that can be either left-aligned, right-aligned or centered. I noticed that if I right-align the textView, any trailing spaces in any of the lines of text in the textView are ignored. This doesn't happen for leading spaces when left-aligning. Visually this is what happens (with '-' to visualize a space): Left-aligned: -some-text- Same text right-aligned: --some-text Adding more text, brings back the trailing space in the correct position: -some-text-b I can't work out why

Detect when the finger lifts after a UISwipeGesture[Recognizer]

南笙酒味 提交于 2019-12-13 13:09:41
问题 I've set up a UISwipeGestureRecognizer : UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:delegate action:@selector(handleSwipeGesture:)]; swipe.direction = UISwipeGestureRecognizerDirectionUp; [self addGestureRecognizer:swipe]; [swipe release]; A swipe makes the player move in the direction of the swipe. I need the player to keep moving, though, until the finger that made the swipe is lifted off the screen. I've tried using the touchesEnded: method but it

Show UIPickerView like a keyboard, without UITextField

前提是你 提交于 2019-12-13 11:37:08
问题 I'm looking for a way to present a UIPickerView when the user taps on a UIBarButtonItem . Imagine a filter for the table view results. I know I could use a UITextField inputView, but this would not be the case -- all I have is a UIBarButtonItem and a UITableView . I've seen into using a UIActionSheet, but it does not look natural, specially when it's animating to show. Would animating the UIView on and off the screen manually the only option? The app is iOS 6+ and iPhone only, so I don't need