uikit

UIButton setTitleColor:forState: question

强颜欢笑 提交于 2019-12-17 18:43:29
问题 Why does the following code work... [signInBtn setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; [signInBtn setTitleColor:[UIColor blackColor] forState:UIControlStateDisabled]; while this does not? [signInBtn setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted|UIControlStateDisabled]; 回答1: I know this is an old question, but these answers aren't correct. When you set each separately you are saying the state property should be UIControlStateHighlighted

Multiple Localized .strings Files in iOS App Bundle

放肆的年华 提交于 2019-12-17 18:42:13
问题 I have a fairly complicated project, consisting of several large localized sub-projects. Most of my sub-projects are localized through a single Localizable.strings file. This file is copied into a SubProjectName.bundle target, which is used in conjunction with a SubProjectName.a static library in the main project. This works fine. However, one of my sub-projects contains many localized .strings files. This project fails to read strings in any language other than English , regardless of how

How can I rotate a UIImageView with respect to any point (other than its center)?

断了今生、忘了曾经 提交于 2019-12-17 18:27:23
问题 By default, a UIImageView will rotate only about its center. How do I get it to rotate about any other point in the image? 回答1: One way of doing this is by changing the anchorPoint of the UIImageView's underlying layer and rotating about that. You can change the point of rotation using something like the following: imageView.layer.anchorPoint = CGPointMake(0.25, 0.25); anchorPoint is defined in terms of relative coordinates within the layer. That is, (0,0) is the upper-left of the layer (on

Why does my view move when I set its frame after changing its anchorPoint?

一世执手 提交于 2019-12-17 17:58:21
问题 I made two instances of UILabel and added them to my ViewController 's view. And then I changed the anchorPoint of each from 0.5 to 1.0 (x and y). Next, I reset the frame of uiLabel2 to its frame I created it with: (100,100,100,20). When I run the app, uiLabel1 and uiLabel2 show at different positions. Why? UILabel *uiLabel1 = [[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 20)] autorelease]; uiLabel1.text = @"UILabel1"; uiLabel1.layer.anchorPoint = CGPointMake(1, 1); UILabel

How to reference controller from a uitableviewcell class in Swift

醉酒当歌 提交于 2019-12-17 17:48:09
问题 I have the following ViewController tableView CustomCell I used a NIB(an .xib file) for the cell, which uses a CustomCell class. This custom cell class handles IBAction for some touch on the cell's button. I'd like to reference the ViewController and some of its variables within it. How am I supposed to do it(accessing ViewController)? Thanks! 回答1: I wouldn't create this kind of dependency between the cell and the view controller - that makes the architecture more intricate and the cell not

How to delete a user default value in NSUserDefaults?

夙愿已清 提交于 2019-12-17 17:42:15
问题 I.e., my app sets some standard default values at the beginning. Then those values may get overridden by the user. And when the user messes things up, I want to set those settings back to my app default values. As I understand it, the app defaults are a different dictionary than the user defaults, and the user defaults just override those app defaults. But I haven't seen methods for deleting the user defaults. Any idea? 回答1: Try removeObjectForKey -- that should give you the ability to remove

Does swift playground support UIKit?

こ雲淡風輕ζ 提交于 2019-12-17 17:34:59
问题 I tried to create a UILabel in playground but failed. Does playground only support OS X development for now? 回答1: YES, it does! File: New > File... > iOS > Source > Playground import UIKit let lbl = UILabel(frame: CGRectMake(0, 0, 300, 100)) lbl.text = "Hello StackOverflow!" Then, save the file. This will trigger the Playground to interpret UI related things. Sometimes you may need to toss in a trailing newline and save again -- its a beta. At this point, the word "UILabel" should appear on

Draw shadow only from 3 sides of UIView

回眸只為那壹抹淺笑 提交于 2019-12-17 17:34:25
问题 I've successfully implemented drawing a shadow around my UIView like this: block1.layer.masksToBounds = NO; block1.layer.shadowOffset = CGSizeMake(0, 0); block1.layer.shadowRadius = 1; block1.layer.shadowOpacity = 0.7; What now happens is I have a rectangular UIView and i would like to draw the shadow around it three sides, leaving the bottom side of it without the shadow. I know that I have to specify the block1.layer.shadowPath by creating a new UIBezierPath but I'm not sure how to do it.

iOS: UIView subclass init or initWithFrame:?

泪湿孤枕 提交于 2019-12-17 17:28:58
问题 I made a subclass of UIView that has a fixed frame. So, can I just override init instead of initWithFrame: ? E.g.: - (id)init { if ((self = [super initWithFrame:[[UIScreen mainScreen] bounds]])) { self.backgroundColor = [UIColor clearColor]; } return self; } The Xcode documentation for -initWithFrame: says: "If you create a view object programmatically, this method is the designated initializer for the UIView class. Subclasses can override this method to perform any custom initialization but

UITableView disable swipe to delete, but still have delete in Edit mode?

丶灬走出姿态 提交于 2019-12-17 17:24:47
问题 I want something similar as the Alarm app, where you can't swipe delete the row, but you can still delete the row in Edit mode. When commented out tableView:commitEditingStyle:forRowAtIndexPath:, I disabled the swipe to delete and still had Delete button in Edit mode, but what happens when I press the Delete button. What gets called? 回答1: Ok, it turns out to be quite easy. This is what I did to solve this: Objective-C - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView