Questions tagged [uikit]

UIKit (not to be confused with the front-end framework GetUIKit) is the object-oriented framework that is responsible for most of the iOS user interface.

UIKit (not to be confused with the front-end framework ) is the object-oriented framework that is responsible for most of the user interface. UIKit is part of the umbrella framework, and it is to Cocoa Touch as AppKit is to the Cocoa framework on macOS. The classes in UIKit determine the basic structure of most iOS applications as well as the majority of distinctive user interface elements that make iOS apps easily recognizable and instantly familiar.

UIKit provides the classes and protocols that lie at the foundation of any iOS application, including:

  • UIApplication
  • UIResponder
  • UIView
  • UIWindow
  • UIControl
  • UIEvent
  • UIViewController
  • UINavigationController
  • UITabBarController
  • UISplitViewController

It also provides the user interface elements with which all iOS users are familiar:

  • UIButton
  • UITextField
  • UITextView
  • UINavigationBar
  • UIToolbar
  • UITabBar
  • UISwitch
  • UILabel
  • UIScrollView
  • UITableView
  • UITableViewCell
  • UIPickerView

These lists are not exhaustive, but only meant to give a sense of the scope of the UIKit framework. A more complete list is found in the UIKit Framework Reference.

11807 questions
148
votes
17 answers

How to change the colors of a segment in a UISegmentedControl in iOS 13?

A UISegmentedControl has a new appearance in iOS 13 and existing code to alter the colors of the segmented control no longer work as they did. Prior to iOS 13 you could set the tintColor and that would be used for the border around the segmented…
rmaddy
  • 314,917
  • 42
  • 532
  • 579
147
votes
8 answers

How to calculate UILabel width based on text length?

I want to display an image next to a UILabel, however UILabel has variable text length, so I don't know where to place the image. How can I accomplish this?
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
141
votes
10 answers

Using a custom image for a UITableViewCell's accessoryView and having it respond to UITableViewDelegate

I'm using a custom drawn UITableViewCell, including the same for the cell's accessoryView. My setup for the accessoryView happens by the way of something like this: UIImage *accessoryImage = [UIImage…
anon
139
votes
9 answers

UITextField border color

I have really great wish to set my own color to UITextField border. But so far I could find out how to change the border line style only. I've used background property to set background color in such way: self.textField.backgroundColor =…
dasha
  • 1,419
  • 2
  • 11
  • 5
138
votes
13 answers

viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller

I'm struggling to find a good solution to this problem. In a view controller's -viewWillDisappear: method, I need to find a way to determine whether it is because a view controller is being pushed onto the navigation controller's stack, or whether…
Michael Waterfall
  • 20,497
  • 27
  • 111
  • 168
138
votes
4 answers

How big should a UIBarButtonItem image be?

I'm looking to create my own custom Sort By Date and Sort By Number buttons that I plan on placing in the navigation bar as the right button. How big should my image be to appropriately fill the space -- the UIBarItem documentation page doesn't list…
Epsilon Prime
  • 4,576
  • 5
  • 31
  • 34
136
votes
11 answers

Displaying a stock iOS notification banner when your app is open and in the foreground?

When Apple's official iOS Messages app is open and in the foreground, new messages from other contacts trigger a stock, native iOS notification alert banner. See image below. Is this possible in 3rd party apps on the App Store? Local and/or Push…
pkamb
  • 33,281
  • 23
  • 160
  • 191
132
votes
4 answers

How can I add CGPoint objects to an NSArray the easy way?

I have about 50 CGPoint objects that describe something like a "path", and I want to add them to an NSArray. It's going to be a method that will just return the corresponding CGPoint for an given index. I don't want to create 50 variables like p1 =…
Thanks
  • 40,109
  • 71
  • 208
  • 322
130
votes
37 answers

UITableViewCell Separator disappearing in iOS7

I have some strange issue with UITableView only in iOS 7. UITableViewCellSeparator disappears above the first row and below the last row. Sometimes after selecting the rows or some scrolling actions it appears. In my case tableView is loaded from…
B.S.
  • 21,660
  • 14
  • 87
  • 109
129
votes
2 answers

How does clipsToBounds work?

I would like to know how to use the UIView property clipsToBounds. The official documentation says the following: clipsToBounds property A Boolean value that determines whether subviews are confined to the bounds of the view. Discussion Setting…
Toshi
  • 6,012
  • 8
  • 35
  • 58
119
votes
5 answers

iOS start Background Thread

I have a small sqlitedb in my iOS device. When a user presses a button, I fetch the data from sqlite & show it to user. This fetching part I want to do it in a background thread (to not block the UI main thread). I do this like so - [self…
Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
118
votes
2 answers

Dispelling the UIImage imageNamed: FUD

Edit Feb 2014: Note that this question dates from iOS 2.0! Image requirements and handling have moved on a lot since then. Retina makes images bigger and loading them slightly more complex. With the built in support for iPad and retina images, you…
Rog
  • 17,070
  • 9
  • 50
  • 73
118
votes
27 answers

How to change UIPickerView height

Is it possible to change the height of UIPickerView? Some applications seem to have shorter PickerViews but setting a smaller frame doesn't seem to work and the frame is locked in Interface Builder.
Steven Canfield
  • 7,312
  • 5
  • 35
  • 28
116
votes
15 answers

How to determine the content size of a UIWebView?

I have a UIWebView with different (single page) content. I'd like to find out the CGSize of the content to resize my parent views appropriately. The obvious -sizeThatFits: unfortunately just returns the current frame size of the webView.
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
115
votes
5 answers

How can I add a boolean value to a NSDictionary?

Well, for integers I would use NSNumber. But YES and NO aren't objects, I guess. A.f.a.i.k. I can only add objects to an NSDictionary, right? I couldn't find any wrapper class for booleans. Is there any?
Thanks
  • 40,109
  • 71
  • 208
  • 322