uikit

Position of rightView UITextField

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 05:32:30
问题 Is there a way to adjust the position of a rightView on UITextField? I tried setting the frame on the view (set as rightView) but it didn't change anything. I'd like to avoid making two views, one as the rightView and one as the rightView's subview where I change the subview's position, if possible. 回答1: The right overlay view is placed in the rectangle returned by the rightViewRectForBounds : method of the receiver. So I suggest you subclass UITextField and override this method, something

Adding border with width to UIView show small background outside

混江龙づ霸主 提交于 2019-12-19 04:25:18
问题 I'm trying to add circle border to a UIView with green background, I created simple UIView subclass with borderWidth, cornerRadius and borderColor properties and I'm setting it from storyboard. @IBDesignable class RoundedView: UIView { @IBInspectable var cornerRadius: CGFloat { get { return layer.cornerRadius } set { layer.cornerRadius = newValue layer.masksToBounds = newValue > 0 } } @IBInspectable var borderWidth: CGFloat { get { return layer.borderWidth } set { layer.borderWidth = newValue

Calculate the height of a UITextView's text with sizeWithFont:constrainedToSize:lineBreakMode doesn't seem to return correct results

旧城冷巷雨未停 提交于 2019-12-19 04:12:16
问题 I'm trying to calculate the height of the text constrained by a UITextView but it doesn't seem to return correct results. Here is my code : - (void)textViewDidChange:(UITextView *)aTextView { CGSize textSize = [aTextView.text sizeWithFont:aTextView.font constrainedToSize:aTextView.frame.size lineBreakMode:UILineBreakModeWordWrap]; counter.text = [NSString stringWithFormat:@"%f", textSize.height]; } You can download the sample project and a short screencast that illustrates the problem (418 KB

Change UIPopoverController color (and back button color)

久未见 提交于 2019-12-19 03:14:12
问题 I try to change the color from a UIPopoverControler on iOS 5. To do so, I use a subclass of UIPopoverBackgroundView that I assign to my popover like this: self.popover.popoverBackgroundViewClass = [KWPopoverBackgroundView class]; My popover is now black as I defined in my KWPopoverBackgroundView class but I still have a problem with the appearance. The back button (Medals) of the navigationController inside my popover is still blue. I want everything unified in black. How do I get rid of this

App crashing on runTransitionForCurrentState but no clue as to why

Deadly 提交于 2019-12-19 02:25:09
问题 I've tried searching for this, but no luck, so hoping there are some guru's who may know the answer. I'm seeing loads of reports in iTunes Connect of my app crashing with a particular stack trace, but the stack trace reveals nothing useful. #0. Crashed: main 0 UIKit 0x1871100c0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 324 1 UIKit 0x1871100bc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 320 2 UIKit 0x1870630c8

Is UIView's opaque property with a value of YES in conflict with its backgroundColor property with a value of [UIColor clearColor]?

放肆的年华 提交于 2019-12-18 19:19:33
问题 such as the code: view.opaque = YES; and view.backgroundColor = [UIColor clearColor]; any one who can explain something about this? EDIT: as the document shows: Declare Views as Opaque Whenever Possible UIKit uses the opaque property of each view to determine whether the view can optimize compositing operations. Setting the value of this property to YES for a custom view tells UIKit that it does not need to render any content behind your view. Less rendering can lead to increased performance

Can't change UINavigationBar prompt color

家住魔仙堡 提交于 2019-12-18 18:58:06
问题 I am unable to change the prompt color on my navigation bar. I've tried the code below in viewDidLoad , but nothing happens. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white] Am I missing something? Is the code above wrong? 回答1: It seems like you're right about this one. You need to use UIAppearance to style the prompt text on iOS 11. I've filed radar #34758558 that the titleTextAttributes property just stopped working for

UIImage's drawInrect: smoothes image

这一生的挚爱 提交于 2019-12-18 18:51:57
问题 I'm trying to draw image using UIImage 's drawInRect: method. Here is the code: UIImage *image = [UIImage imageNamed:@"OrangeBadge.png"]; UIGraphicsBeginImageContext(image.size); [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); The problem is that the resulting image is blurry. Here is the resulting image (on the right side) compared to the source image (on the left side):

How to calculate the size of a UIFont when text in label is constrained down to fit width?

南笙酒味 提交于 2019-12-18 16:56:51
问题 Imagine a UILabel, which is 200 pixels wide and 50 pixels high. The label has text inside, and the label makes the text smaller so that it fits into the label. But now, how would you get the size of that UIFont how it is visible in the label? Lets imagine the font size was given with huge 100, and the label squeezes it down to 15. And then, you want to make some other labels with little text, which has same font size. Is there a way to obtain the UIFont's font size after getting squeezed by

shouldReceiveTouch on UITableViewCellContentView

 ̄綄美尐妖づ 提交于 2019-12-18 14:49:50
问题 I'm trying to ignore UITapGestureRecognizer taps on a UITableView with the following: - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isKindOfClass:[UITableViewCellContentView class]]) { return NO; // ignore the touch } return YES; // handle the touch } It won't compile: "Use of undeclared identifier 'UITableViewCellContentView' Undocumented class? Need to subclass? Better way to accomplish this? Thanks for any help. 回答1