uikit

Appearance proxies / UI_APPEARANCE_SELECTOR in Swift?

不羁的心 提交于 2019-12-13 11:34:33
问题 The Apple documentation states: To participate in the appearance proxy API, tag your appearance property selectors in your header with UI_APPEARANCE_SELECTOR. In Objective-C one can annotate properties with UI_APPEARANCE_SELECTOR like this: @property (nonatomic, strong) UIColor *foregroundColor UI_APPEARANCE_SELECTOR; How can I do the same in Swift? 回答1: Mark your custom view property as dynamic . For example: class YourCustomView: UIView { @objc dynamic var subviewColor: UIColor? { get {

How to pass data between view controllers - not working

南笙酒味 提交于 2019-12-13 10:56:25
问题 Im trying to pass an player score from VC1 to a view that displays the current scores of all players(4). the display view is on a separate view controller than where the player(s) score is defined and stored. I have done the prepare(segue) and im able to pass other variables to the display VC(ThirdViewController). but when I try to assign the player score to the uilabel.text It tells me that I have unwrapped a nil value I have even tried to just set the label text to a static string and still

How can I build a custom UITabBar?

只愿长相守 提交于 2019-12-13 09:36:43
问题 I want to build a custom UITabBar with a white background color, rounded corners, a smaller width, and a custom indicator (see picture). Can I subclass UITabBar/UITabBarController or do I have to create a new view manually? And how can I do that? Many thanks! 回答1: Ok... firstly you can open the storyboard and set a nice pink background color, then you can add a UIView. You can set a proportional height and width to the superview like a 0.9 to the width and a 0.12 to the height, then a center

Can I set the origin of rotation when rotating an view with CGAffineTransformMakeRotation()?

不羁岁月 提交于 2019-12-13 09:25:01
问题 I have an UIImageView which I want to rotate a little bit, but I need to define an special origin for rotation. How could I do that? More precisely, I have an image of a goblet, and I want it to wiggle on a table. It's socket is quadrate. So when wiggeling to left, then my rotation origin has to be the left corner of that quadrate. And when wiggeling to right, the rotation origin has to be the right corner of that quadrate. How could I do that? I already have this: myView.transform =

UIButton iOS 7 following UIKeyboard animation

风格不统一 提交于 2019-12-13 08:51:50
问题 I would like to animate a UIButton which is at the bottom of my UIView when the keyboard becomes/resigns first responder. Before iOS 7 I made a simple animation that moves the button, but now the animation of the keyboard is non linear, it starts faster and ends more slowly. I've been told to do it with the new UIKit Dynamics but don't have any idea of how can I achieve my goal. Any suggestion? Thanks in advance. 回答1: Listen to keyboard notifications. There you can obtain the following

Unknown type name 'CGVector'; did you mean 'CIVector'?

◇◆丶佛笑我妖孽 提交于 2019-12-13 08:13:25
问题 I am working in a project i started in the last Xcode 4 version and when i open and try tu run it using the new Xcode 5 i get this error in both UIPushBehavior.h and UIGravityBehavior.h. /Applications/xcode 4/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIPushBehavior.h:34:34: Unknown type name 'CGVector'; did you mean 'CIVector'? and does not compile my project. Any ideas on how to fix this will be

How can I know when any of the objects on screen were tapped?

谁都会走 提交于 2019-12-13 06:50:39
问题 Now first of all, I am not asking how to add a gesture recognizer or how to create a button. What I want is to know that "somebody touched the screen in any way", without interfering with the related screen element. The thing is that I have elements that the user can tap on (amazing, isn't it?). Then I have a view that is overlaid on top of everything (window addSubview). This view shows up with some delay, and I want the app to behave as if this view wasn't there until its "show" animation

Adding UIPicker to textfield

▼魔方 西西 提交于 2019-12-13 05:09:47
问题 I have a table view & I have to display text fields in some cells. When user click on the text field, I want the picker view to be displayed with integer values from 0 to 99. once the user selects the item in picker view the same needs to be displayed on that particular text field. Any help would be sincerely appreciated. 回答1: -(void) viewDidLoad { arrayNo = [[NSMutableArray alloc] init]; [arrayNo addObject:@"1"]; [arrayNo addObject:@"2"]; [arrayNo addObject:@"3"]; // and so on.... } Add

Drawing getting pixelated in iOS

无人久伴 提交于 2019-12-13 05:08:53
问题 I am working on a drawing application, I am drawing into CGlayers , I am creating a CGlayer this way -(void)drawRect { if(self.DrawingLayer == nil) { CGFloat scale = self.contentScaleFactor; CGRect bounds = CGRectMake(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); CGLayerRef layer = CGLayerCreateWithContext(context, bounds.size, NULL); CGContextRef layerContext = CGLayerGetContext(layer); CGContextScaleCTM(layerContext, scale, scale); self.DrawingLayer = layer; }

warning: passing argument 1 of 'numberWithBool:' with different width due to prototype

只谈情不闲聊 提交于 2019-12-13 04:59:51
问题 The compiler complains about this, after I activated all kind of warnings: I create an NSNumber like this: NSNumber *num = [NSNumber numberWithBool:YES]; warning: passing argument 1 of 'numberWithBool:' with different width due to prototype it complains about the value I provided. What's wrong with "YES"? What does that mean? 回答1: It means that you have turned on one of the über-anal warnings about type coercion related to size changes. The compiler is complaining -- likely erroneously, from