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

Use recursion: // UIView+HierarchyLogging.h @interface UIView (ViewHierarchyLogging) – (void)logViewHierarchy; @end // UIView+HierarchyLogging.m @implementation UIView (ViewHierarchyLogging) – (void)logViewHierarchy { NSLog(@”%@”, self); for (UIView *subview in self.subviews) { [subview logViewHierarchy]; } } @end // In your implementation [myView logViewHierarchy];

Draw dotted (not dashed!) line, with IBDesignable in 2017

Set the line cap style to round and set the “on” length to a tiny number. Swift playground example: import UIKit import PlaygroundSupport let path = UIBezierPath() path.move(to: CGPoint(x:10,y:10)) path.addLine(to: CGPoint(x:290,y:10)) path.lineWidth = 8 let dashes: [CGFloat] = [0.001, path.lineWidth * 2] path.setLineDash(dashes, count: dashes.count, phase: 0) path.lineCapStyle = CGLineCap.round UIGraphicsBeginImageContextWithOptions(CGSize(width:300, height:20), false, 2) UIColor.white.setFill() … Read more

Loading an “overlay” when running long tasks in iOS

The above answers add a loading view but it doesn’t block click events on the screen also it does not provides overlay for rest of screen. You can achieve it as follows: let alert = UIAlertController(title: nil, message: “Please wait…”, preferredStyle: .Alert) alert.view.tintColor = UIColor.blackColor() let loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(10, 5, 50, 50)) as … Read more

Draw line in UIView

Maybe this is a bit late, but I want to add that there is a better way. Using UIView is simple, but relatively slow. This method overrides how the view draws itself and is faster: – (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); // Draw them with a 2.0 stroke width … Read more

How to Convert UIView to PDF within iOS?

Note that the following method creates just a bitmap of the view; it does not create actual typography. (void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename { // Creates a mutable data object for updating with binary data, like a byte array NSMutableData *pdfData = [NSMutableData data]; // Points the pdf converter to the mutable data object and to the UIView … Read more

Setting alpha on UIView sets the alpha on its subviews which should not happen

I think this is a bug in the documentation. You should file it at bugreport.apple.com. Everything I can see after a bit of quick research suggests what you are seeing is how it always has behaved, and my own testing shows it too. The alpha of a view is applied to all subviews. Perhaps all … Read more

How to list out all the subviews in a uiviewcontroller in iOS?

You have to recursively iterate the sub views. – (void)listSubviewsOfView:(UIView *)view { // Get the subviews of the view NSArray *subviews = [view subviews]; for (UIView *subview in subviews) { // Do what you want to do with the subview NSLog(@”%@”, subview); // List the subviews of subview [self listSubviewsOfView:subview]; } }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)