touchesended

Resizable Centered Circular UIView

无人久伴 提交于 2020-01-01 19:35:14
问题 I am looking for a way to create a CIRCULAR UIView that is resizable and stays centered ( see image ). The CIRCULAR view in this example is a UIView subclass WCSDailyGoal . ContainerView.m - (void)createDailyGoalView { _dailyGoalView = [[WCSDailyGoalView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; _dailyGoalView.delegate = self; _dailyGoalView.goal = 200; _dailyGoalView.center = self.view.center; [self.view addSubview:_dailyGoalView]; } WCSDailyGoal.m - (void)setGoal:(CGFloat)goal {

How to change UISlider Thumb Appearance when Touch Ends

China☆狼群 提交于 2019-12-12 04:25:53
问题 I am changing the color of a UISlider by calling .thumbTintColor @IBAction func slider1Master(sender: AnyObject) { slider1.thumbTintColor = UIColor.orangeColor()} It works, but I want the color to change back to it's original state when the touch ends (user lifts finger). Does anyone have any suggestions? Thank you. 回答1: You can use " setThumbImage " instead. Then you have the option of setting an image for a specific state of action. For the image, just create a rounder image with the color

How to know when the button is pressed and canceled Button pressing

大城市里の小女人 提交于 2019-12-11 08:26:43
问题 I made a button. And used the below code. But it doesn't work at all. override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) { print("pressTest") btnConvert.isHidden = true } How can I know when the button is pressed and when button pressing is canceled? 回答1: Use the built-in UIButton functions - .touchDown , .touchUpInside , .touchUpOutside . Touch begin: myButton.addTarget(target, action: action, for: .touchDown) Touch ends: myButton.addTarget(target, action:

Resizable Centered Circular UIView

筅森魡賤 提交于 2019-12-04 19:44:56
I am looking for a way to create a CIRCULAR UIView that is resizable and stays centered ( see image ). The CIRCULAR view in this example is a UIView subclass WCSDailyGoal . ContainerView.m - (void)createDailyGoalView { _dailyGoalView = [[WCSDailyGoalView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; _dailyGoalView.delegate = self; _dailyGoalView.goal = 200; _dailyGoalView.center = self.view.center; [self.view addSubview:_dailyGoalView]; } WCSDailyGoal.m - (void)setGoal:(CGFloat)goal { CGPoint saveCenter = self.center; CGRect newFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y,