uiview

Adding UICollectionViewController to UIViewController Not Working

这一生的挚爱 提交于 2021-02-10 22:22:55
问题 I have a UIViewController and a UICollectionViewController . I add the UICollectionViewController to the UIViewController using the following: UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; self.toolsCollectionViewController = [[ToolsCollectionViewController alloc] initWithCollectionViewLayout:flowLayout]; self.toolsCollectionViewController.view.backgroundColor = [UIColor clearColor]

Repeat animation from left to right smoothly

只谈情不闲聊 提交于 2021-02-10 06:53:08
问题 I'm trying to animate 3 squares from the left to the right. The squares should reappear from the left while they are disappearing from the right. The idea is that the squares represent clouds, so the idea is clear. This is what I currently got: class ViewController: UIViewController { // contains the squares @IBOutlet weak var containerView: UIView! override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) startAnimating(

iOS - Display a progress indicator at the center of the screen rather than the view

ぃ、小莉子 提交于 2021-02-10 03:26:17
问题 I want to display a progress indicator at the center of the screen, NOT the view. It should be the center of the view because the view is scrollable. Most answers only tells how to center it in the view. I have this code: let screenBound = UIScreen.main.bounds let progressIndc = UIActivityIndicatorView() progressIndc.frame = CGRect(x: screenBound.width / 2 - 10, y: screenBound.height / 2 - 10, width: 20, height: 20) progressIndc.hidesWhenStopped = true progressIndc.color = UIColor.gray

iOS - Display a progress indicator at the center of the screen rather than the view

我与影子孤独终老i 提交于 2021-02-10 03:23:58
问题 I want to display a progress indicator at the center of the screen, NOT the view. It should be the center of the view because the view is scrollable. Most answers only tells how to center it in the view. I have this code: let screenBound = UIScreen.main.bounds let progressIndc = UIActivityIndicatorView() progressIndc.frame = CGRect(x: screenBound.width / 2 - 10, y: screenBound.height / 2 - 10, width: 20, height: 20) progressIndc.hidesWhenStopped = true progressIndc.color = UIColor.gray

iOS - Display a progress indicator at the center of the screen rather than the view

邮差的信 提交于 2021-02-10 03:23:30
问题 I want to display a progress indicator at the center of the screen, NOT the view. It should be the center of the view because the view is scrollable. Most answers only tells how to center it in the view. I have this code: let screenBound = UIScreen.main.bounds let progressIndc = UIActivityIndicatorView() progressIndc.frame = CGRect(x: screenBound.width / 2 - 10, y: screenBound.height / 2 - 10, width: 20, height: 20) progressIndc.hidesWhenStopped = true progressIndc.color = UIColor.gray

iOS - Display a progress indicator at the center of the screen rather than the view

若如初见. 提交于 2021-02-10 03:21:24
问题 I want to display a progress indicator at the center of the screen, NOT the view. It should be the center of the view because the view is scrollable. Most answers only tells how to center it in the view. I have this code: let screenBound = UIScreen.main.bounds let progressIndc = UIActivityIndicatorView() progressIndc.frame = CGRect(x: screenBound.width / 2 - 10, y: screenBound.height / 2 - 10, width: 20, height: 20) progressIndc.hidesWhenStopped = true progressIndc.color = UIColor.gray

UITableView in UIView in UIScrollView. When scrolling tableview don't scroll scrollview too

99封情书 提交于 2021-02-09 08:49:07
问题 I have a UITableView inside a UIView inside a UIScrollView. Problem: when i scroll/drag the tableview, the scrollview scrolls too. What i need is for the tableview not to pass the scroll to the scrollview. Also i need to be able to use the scrollview when i scroll it directly. How can i do this? Cheers 回答1: I fixed it using "hitTest" on the tableview. - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event If the event originated within the tableview, i disable the parent's scrollview

Tap Gesture Recognizer not received in custom UIView embedded in super view

回眸只為那壹抹淺笑 提交于 2021-02-08 11:26:59
问题 I am trying to create a custom UIView/Scrollview named MyScrollView that contains a few labels (UILabel), and these labels receive tap gestures/events in order to respond to user's selections . In order to make the tap event work on the UILabels, I make sure they all have userIteractionEnabled = true and I created a delegate as below: protocol MyScrollViewDelegate { func labelClicked(recognizer: UITapGestureRecognizer) } The custom UIView is being used in ScrollViewController that I created,

UIView.layer.presentationLayer returns final value (rather than current value)

我们两清 提交于 2021-02-08 10:53:24
问题 Here's some relevant code inside a UIView subclass : - (void) doMyCoolAnimation { CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"position.x"]; anim.duration = 4; [self.layer setValue:@200 forKeyPath:anim.keyPath]; [self.layer addAnimation:anim forKey:nil]; } - (CGFloat) currentX { CALayer* presLayer = self.layer.presentationLayer; return presLayer.position.x; } When I use [self currentX] while the animation is running, I get 200 (the end value) rather than a value between 0

UIView.layer.presentationLayer returns final value (rather than current value)

≯℡__Kan透↙ 提交于 2021-02-08 10:52:46
问题 Here's some relevant code inside a UIView subclass : - (void) doMyCoolAnimation { CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"position.x"]; anim.duration = 4; [self.layer setValue:@200 forKeyPath:anim.keyPath]; [self.layer addAnimation:anim forKey:nil]; } - (CGFloat) currentX { CALayer* presLayer = self.layer.presentationLayer; return presLayer.position.x; } When I use [self currentX] while the animation is running, I get 200 (the end value) rather than a value between 0