All Questions

Tagged with
Filter by
Sorted by
Tagged with
241 votes
8 answers
147k views

iPhone - Get Position of UIView within entire UIWindow

The position of a UIView can obviously be determined by view.center or view.frame etc. but this only returns the position of the UIView in relation to it's immediate superview. I need to determine the ...
adam's user avatar
  • 22.5k
188 votes
27 answers
127k views

Dashed line border around UIView

How do I add dashed line border around UIView. Something Like this
Sohaib's user avatar
  • 11.1k
168 votes
12 answers
147k views

Given a view, how do I get its viewController?

I have a pointer to a UIView. How do I access its UIViewController? [self superview] is another UIView, but not the UIViewController, right?
mahboudz's user avatar
  • 39.3k
149 votes
24 answers
97k views

Handling an empty UITableView. Print a friendly message

I have a UITableView that in some cases it is legal to be empty. So instead of showing the background image of the app, I would prefer to print a friendly message in the screen, such as: This list ...
cateof's user avatar
  • 6,668
142 votes
8 answers
214k views

iPhone UIView Animation Best Practice

What is considered best practice for animating view transitions on the iPhone? For example, the ViewTransitions sample project from apple uses code like: CATransition *applicationLoadViewIn = [...
Keith Fitzgerald's user avatar
138 votes
9 answers
156k views

How to draw a custom UIView that is just a circle - iPhone app

How would I go about drawing a custom UIView that is literally just a ball (a 2D circle)? Would I just override the drawRect method? And can someone show me the code for drawing a blue circle? Also, ...
StanLe's user avatar
  • 5,107
137 votes
8 answers
57k views

iPhone SDK: what is the difference between loadView and viewDidLoad?

When working with views and view controllers in an iPhone app, can anyone explain the difference between loadView and viewDidLoad? My personal context, is that I build all my views from code, I do ...
ryan.scott's user avatar
  • 2,215
136 votes
14 answers
74k views

Changing my CALayer's anchorPoint moves the view

I want to alter the anchorPoint, but keep the view in the same place. I've tried NSLog-ing self.layer.position and self.center and they both stay the same regardless of changes to the anchorPoint. Yet ...
Kenny Winker's user avatar
125 votes
14 answers
67k views

Rounded UIView using CALayers - only some corners - How?

In my application - there are four buttons named as follows: Top - left Bottom - left Top - right Bottom - right Above the buttons there is an image view (or a UIView). Now, suppose a user taps on -...
sagarkothari's user avatar
  • 24.7k
118 votes
8 answers
111k views

Get position of UIView in respect to its superview's superview

I have a UIView, in which I have arranged UIButtons. I want to find the positions of those UIButtons. I am aware that buttons.frame will give me the positions, but it will give me positions only ...
Shailesh's user avatar
  • 3,100
112 votes
8 answers
90k views

CALayers didn't get resized on its UIView's bounds change. Why?

I have a UIView which has about 8 different CALayer sublayers added to its layer. If I modify the view's bounds (animated), then the view itself shrinks (I checked it with a backgroundColor), but the ...
Geri Borbás's user avatar
  • 16.2k
108 votes
17 answers
34k views

"From View Controller" disappears using UIViewControllerContextTransitioning

I got one problem and i have described it below. I am using UIViewControllerContextTransitioning for custom transitions. I have 2 view controllers, first view controller and second view controller. ...
NiravPatel's user avatar
  • 3,260
107 votes
2 answers
48k views

What is the relationship between UIView's setNeedsLayout, layoutIfNeeded and layoutSubviews?

Can anyone give a definitive explanation on the relationship between UIView's setNeedsLayout, layoutIfNeeded and layoutSubviews methods? And an example implementation where all three would be used. ...
Tarfa's user avatar
  • 1,145
102 votes
4 answers
97k views

How to create a UIView bounce animation?

I have the following CATransition for a UIView called finalScoreView, which makes it enter the screen from the top: CATransition *animation = [CATransition animation]; animation.duration = 0.2; ...
WunDaii's user avatar
  • 2,322
102 votes
10 answers
46k views

Interaction beyond bounds of UIView

Is it possible for a UIButton (or any other control for that matter) to receive touch events when the UIButton's frame lies outside of it's parent's frame? Cause when I try this, my UIButton doesn't ...
ThomasM's user avatar
  • 2,667
101 votes
6 answers
105k views

Correct way to load a Nib for a UIView subclass

I am aware this question has been asked before but the answers are contradicting and I am confused, so please don't flame me. I want to have a reusable UIView subclass throughout my app. I want to ...
Adam Waite's user avatar
  • 19.2k
97 votes
13 answers
105k views

Determine whether UIView is visible to the user?

Is it possible to determine whether my UIView is visible to the user or not? My View is added as a subview several times into a UITabBarController. Each instance of this view has an NSTimer that ...
jantimon's user avatar
  • 37.4k
94 votes
7 answers
31k views

iOS White to Transparent Gradient Layer is Gray

I have a CAGradientLayer inserted to the bottom of this small detail view that pops up at the bottom of the app. As you can see, I've set the colors from white to clear, but there's this strange gray ...
Eric Gao's user avatar
  • 3,532
90 votes
9 answers
154k views

Draw line in UIView

I need to draw a horizontal line in a UIView. What is the easiest way to do it. For example, I want to draw a black horizontal line at y-coord=200. I am NOT using Interface Builder.
John Smith's user avatar
  • 12.7k
88 votes
18 answers
91k views

How can I loop through all subviews of a UIView, and their subviews and their subviews

How can I loop through all subviews of a UIView, and their subviews and their subviews?
123hal321's user avatar
  • 2,090
88 votes
4 answers
64k views

Difference between addSubview and insertSubview in UIView class

What is the difference between addSubview and insertSubView methods when a view is added programmatically?
Ashwani K's user avatar
  • 7,900
84 votes
9 answers
70k views

How can I do Key Value Observing and get a KVO callback on a UIView's frame?

I want to watch for changes in a UIView's frame, bounds or center property. How can I use Key-Value Observing to achieve this?
hfossli's user avatar
  • 22.8k
83 votes
1 answer
39k views

UIView - How to get notified when the view is loaded?

Is there anything similar to the viewDidLoad of UIViewController for a UIView??? I need to be notified as soon as a UIView has loaded (Subclass of UIView), and perform some actions.
aryaxt's user avatar
  • 77k
79 votes
7 answers
128k views

Adding padding to an UIView

I'm looking for a way to add a padding property to an UIView. Ideally, I would like to avoid subclassing and putting it in a category. The usage would be something like: myview.padding = ...
Meda's user avatar
  • 2,876
76 votes
7 answers
84k views

Drawing UIBezierPath on code generated UIView

I have a UIView added in code at run time. I want to draw a UIBezierPath in it, but does this means i have to override the drawRect for UIView? Or is there another way of drawing to it on the custom ...
Itzik984's user avatar
  • 16.4k
74 votes
10 answers
128k views

How to fill background image of an UIView

I have an UIView and I set a background image in this way: self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sfond-appz.png"]]; My problem is that back-image is not ...
Jayyrus's user avatar
  • 13.1k
74 votes
11 answers
64k views

How to achieve UIButton / UILabel 'padding' in iPhone app

I've got various views in my iPhone application that require padding e.g a custom UIButton with text aligned left, and a UILabel with a background color. This may be a really stupid question, but how ...
user avatar
74 votes
5 answers
78k views

Passing through touches to UIViews underneath

I have a UIView with 4 buttons on it and another UIView on top of the buttons view. The top most view contains a UIImageView with a UITapGestureRecognizer on it. The behavoir I am trying to create ...
Magic Bullet Dave's user avatar
74 votes
8 answers
120k views

How to add an UIViewController's view as subview

Note to googlers, this Q-A is now six years out of date! As Micky below and others mention, this is now done on an everyday basis with Containers in iOS. I have a ViewController which controls many ...
sperumal's user avatar
  • 749
71 votes
4 answers
41k views

UIView hide children views when out of bounds

I have a view, lets say 100x100. And it has set of uiviews as subviews: let say 30x30 If a subview has top-left coordinate: (90,90) - I expect to see only part of this subview. But I still see entire ...
user349302's user avatar
  • 3,621
66 votes
7 answers
67k views

How to make a circular UIView

I want to make a UIView or UIImageView that is a circle. Or a circle that i can change the size of using a slider, and the color of with a pickerview.
Jab's user avatar
  • 27.3k
65 votes
6 answers
84k views

addSubview animation

I have main UIView where I display different data. Then I put a button, which displays subview like this: - (IBAction) buttonClicked:(id)sender { UIView *newView = [[UIView alloc] initWithFrame:...
Mike's user avatar
  • 1,712
63 votes
9 answers
43k views

View got hidden below UINavigationBar iOS 7

Earlier, I was using iOS 6.1 for my project. Recently I have switched to iOS 7. For, a lot of changes I knew, I updated my code.. But I have observed a strange behavior. My view on every screen gets ...
Salman Zaidi's user avatar
  • 9,592
63 votes
3 answers
57k views

iPhone how to check the type of an Object?

I want to check the type of an Object. How can I do that? The scenario is I'm getting an object. If that object is of type A then do some operations. If it is of type B then do some operations. ...
g.revolution's user avatar
  • 12.1k
62 votes
4 answers
65k views

How to force layoutSubviews of UIView?

I have a custom UIView which has a dedicated, manually set frame for portrait and landscape orientation because autoresizingMasks just don't work in my case. I set this frame in: - (void)...
myell0w's user avatar
  • 2,210
60 votes
3 answers
41k views

UIView: opaque vs. alpha vs. opacity

How do opaque alpha and the opacity of the background work together for a UIView and what are the differences between them? UIView http://i.minus.com/jb2IP8TXbYTxKr.png
Besi's user avatar
  • 22.8k
59 votes
5 answers
55k views

Set UIView's autoresizing mask programmatically?

I have to set autoresizingMask programmatically for UIView. I don't know how to implement this.
Hiren's user avatar
  • 12.7k
58 votes
11 answers
118k views

How to add a footer to the UITableView?

I'me using this code to add a footer to the TableView. It has 20 sections, and each section a few rows. There's a titleForHeaderInSection, and sectionForSectionIndexTitle methods. CGRect footerRect = ...
Rui Lopes's user avatar
  • 2,562
56 votes
3 answers
51k views

Laying out & sizing of subviews in a UIViewController

I have an app with with a UITabController and each tab is a UINavigationController. The root of one of my UINavigationControllers is a UIViewController. Inside that view controller's view, I want to ...
Michael Waterfall's user avatar
55 votes
3 answers
46k views

What are block-based animation methods in iPhone OS 4.0?

I am trying to implement a game using the iPhone OS 4.0 (iOS4?) SDK. In the previous versions of the SDK, I've been using the [UIView beginAnimations:context:] and [UIView commitAnimations] to create ...
kkrizka's user avatar
  • 893
55 votes
5 answers
42k views

UIView did appear?

I'm wondering, is there a way to get a delegate or something, when a particular UIView has been shown on the screen ?
nosuic's user avatar
  • 1,360
54 votes
6 answers
42k views

How to make a UIView always appear at the front?

Currently I have a UIView which contains some controls. I then have some images I programatically add to the view to display as animations. Currently at the end of each interval of my game loop im ...
woot586's user avatar
  • 3,946
53 votes
12 answers
38k views

How to draw a "speech bubble" on an iPhone?

I'm trying to get a "speech bubble" effect similar to the one in Mac OS X when you right click on something in the dock. Here's what I have now: I need to get the "triangle" part of the lower ...
sudo rm -rf's user avatar
  • 29.5k
52 votes
6 answers
73k views

Remove Auto-Layout Constraints for Specific Object

I have a UIImageView embedded in a UIView. My entire app uses AutoLayout, but I want to remove constraints for the UIImageView. Xcode will not allow me to delete the constraints, is there a way to ...
Eric's user avatar
  • 4,063
49 votes
12 answers
86k views

How to disable touch input to all views except the top-most view?

I have a view with multiple subviews. When a user taps a subview, the subview expands in size to cover most of the screen, but some of the other subviews are still visible underneath. I want my app ...
MusiGenesis's user avatar
  • 74.7k
48 votes
3 answers
29k views

What UIView layer.masksToBounds is doing if set to YES?

Anyone know? I found a few answers, but there were too complex and going too deep. I need a simple answer.
Ondrej Rafaj's user avatar
  • 4,362
48 votes
4 answers
20k views

How to animate layer shadowOpacity?

I have a view on which I've set the layerOpacity to 1. theView.layer.shadowOpacity = 1.0; This looks fine when the view is farther down the screen. When I move this view up to be flush with ...
sudo rm -rf's user avatar
  • 29.5k
48 votes
4 answers
106k views

Changing UIView size programmatically

I've a UIView, I want to change the size when user touches a button. CGRect newFrame = self.myview.frame; newFrame.size.width = 200; newFrame.size.height = 200; [self setFrame:newFrame]; CGRect ...
onivi's user avatar
  • 1,348
44 votes
6 answers
44k views

Orientation in a UIView added to a UIWindow

I have a UIView which is supposed to cover the whole device (UIWindow) to support an image zoom in/out effect I'm doing using core animation where a user taps a button on a UITableViewCell and I zoom ...
Ken's user avatar
  • 783
44 votes
18 answers
34k views

iOS: Detect if the device is iPhone X family (frameless)

In my app there is some logic for frameless devices (iPhoneX, Xs Xs max, Xr). Currently it works base on the model of the devices, so, I detect the model by DeviceKit framework. But I want to extend ...
Mark cubn's user avatar
  • 527

1
2 3 4 5
90