Add UITextField on UIView programmatically

If you want one looking like the text field in Interface builder: UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)]; textField.borderStyle = UITextBorderStyleRoundedRect; textField.font = [UIFont systemFontOfSize:15]; textField.placeholder = @”enter text”; textField.autocorrectionType = UITextAutocorrectionTypeNo; textField.keyboardType = UIKeyboardTypeDefault; textField.returnKeyType = UIReturnKeyDone; textField.clearButtonMode = UITextFieldViewModeWhileEditing; textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; textField.delegate = self; [self.view addSubview:textField]; [textField release];

How to take screenshot of a UIView in swift?

For drawing of one view, just use this: // Begin context UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.mainScreen().scale) // Draw view in that context drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) // And finally, get image let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() If you want to use it multiple times, probably extension would do the job: //Swift4 extension UIView { func takeScreenshot() -> UIImage … Read more

What is the correct way to remove a subview from a view hierarchy and nuke it?

Try this: UIView *v = [self.containerView viewWithTag:[n integerValue]]; v.hidden = YES; [self.containerView bringSubviewToFront:v]; [v removeFromSuperview]; Another thing I just noticed from the UIView class document – see the last sentence: removeFromSuperview Unlinks the receiver from its superview and its window, and removes it from the responder chain. (void)removeFromSuperview Discussion If the receiver’s superview is not … Read more

How to make UIView animation sequence repeat and autoreverse

To animation from point 1 to 2 to 3 to 2 to 1 and repeat, you can do use animateKeyframesWithDuration in iOS 7 and later: someView.frame = frame1; [UIView animateKeyframesWithDuration:2.0 delay:0.0 options:UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat animations:^{ [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{ someView.frame = frame2; }]; [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{ someView.frame = frame3; }]; } completion:nil]; If using … Read more

UIView animation based on UIPanGestureRecognizer velocity

The docs say The velocity of the pan gesture, which is expressed in points per second. The velocity is broken into horizontal and vertical components. So I’d say, given you want to move your view xPoints (measured in pt) to let it go off-screen, you could calculate the duration for that movement like so: CGFloat … Read more

How to disable multitouch?

If you want only one button to respond to touches at a time, you need to set exclusiveTouch for that button, rather than for the parent view. Alternatively, you could disable the other buttons when a button gets the “Touch Down” event. Here’s an example of the latter, which worked better in my testing. Setting … Read more

iOS UIView Background Image

you are required to process your image before you add it, try this : UIGraphicsBeginImageContext(self.view.frame.size); [[UIImage imageNamed:@”image.png”] drawInRect:self.view.bounds]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); self.view.backgroundColor = [UIColor colorWithPatternImage:image];

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