uibutton

Rotate UIButton 360 degrees

无人久伴 提交于 2020-07-17 09:37:18
问题 I've been trying to run an animation that rotates my UIButton 360 degrees using this code: UIView.animateWithDuration(3.0, animations: { self.vineTimeCapButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI*2)) self.instagramTimeCapButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI*2)) }) However, it doesn't rotate 360 degrees because the UIButton is already at that location. How can I rotate my UIButton 360 degrees? 回答1: You can use a trick: start rotating with 180 degrees

UIButton targets not working if a UIView is added as a subview

馋奶兔 提交于 2020-07-17 09:28:29
问题 I have a UIButton . It has two subviews. I then call: [createButton addTarget:self action:@selector(openComposer) forControlEvents:UIControlEventTouchUpInside]; If I tap the parts of the UIButton that aren't covered but one of its subviews, it works fine. However if I tap one of the subviews instead, it does not trigger the action. On both subviews, I has .userInteractionEnabled set to YES . Both subviews are plain UIViews s with a frame and backgroundColor . How can I get the tap to "pass

UIButton targets not working if a UIView is added as a subview

拜拜、爱过 提交于 2020-07-17 09:28:06
问题 I have a UIButton . It has two subviews. I then call: [createButton addTarget:self action:@selector(openComposer) forControlEvents:UIControlEventTouchUpInside]; If I tap the parts of the UIButton that aren't covered but one of its subviews, it works fine. However if I tap one of the subviews instead, it does not trigger the action. On both subviews, I has .userInteractionEnabled set to YES . Both subviews are plain UIViews s with a frame and backgroundColor . How can I get the tap to "pass

UIButton Click Event not working if I add UITapGestureRecognizer in swift

♀尐吖头ヾ 提交于 2020-07-14 04:15:07
问题 On my login page, if I focus to UITextEdit for entering email and password, keyboard appears and login page scroll up. And I add this code for remove keyboard if I touch outside of keyboard. extension UIViewController { func hideKeyboardWhenTappedAround() { let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard)) tap.cancelsTouchesInView = false view.addGestureRecognizer(tap) } @objc func dismissKeyboard() { view.endEditing

UIButton blocking touchesBegan and touchesMoved

◇◆丶佛笑我妖孽 提交于 2020-07-13 15:36:25
问题 I'm writing an app for tvOS - and it all works until I put a UIButton on the screen. The problem, when buttons are added, is that touchesBegan and touchesMoved stop working. If I remove the buttons then touchesBegan and touchesMoved start working correctly again. I have tried, in the interests of experimentation, unchecking 'User Interaction Enabled' - but this didn't make any difference. I have also tried subclassing UIButton and adding the following code: - (void)touchesBegan:(NSSet *

UIButton pass-through tap-and-scroll gesture to UIScrollView

风格不统一 提交于 2020-06-12 08:59:11
问题 I have a horizontal paginated UIScrollView with a UIButton partially covering the scroll view. Like this: UIView | |- UIScrollView | |- UIButton I want to make the UIButton to not trigger on tap-scroll-and-relase-above-the-button (I want the UIScrollView to scroll instead). I want the button to only respond to tap-and-release-without-moving . Can this easy and quickly done? Or should I subclass the UIButton and override -touchesBegan: , etc., to manually pass the touches to the scrollView

Changing font color of UIBarButtonItem

寵の児 提交于 2020-06-11 16:53:07
问题 I tried to change the font color of the right bar button item to purple, but it still shows up as white. I've consulted this question and this question. How do I fix this? Code let sortButton = UIButton(frame: CGRect(x: 0, y: 0, width: 34, height: 15)) sortButton.setTitle("SORT", for: .normal) sortButton.titleLabel?.tintColor = UIColor.myMusicPurple sortButton.tintColor = UIColor.myMusicPurple navigationItem.rightBarButtonItem = UIBarButtonItem(customView: sortButton) navigationItem

UIButton with multiple target actions for same event

淺唱寂寞╮ 提交于 2020-05-30 08:23:45
问题 Can I add multiple target actions on a UIButton for the same event like below? [button addTarget:self action:@selector(xxx) forControlEvents:UIControlEventTouchUpInside]; [button addTarget:object action:@selector(yyy) forControlEvents:UIControlEventTouchUpInside]; I made a quick app to test it out and it carries out both the actions on button press. I want to know if it's good practice to do so, and also will the order of execution always remain the same? Thanks in advance. Edit: I did find

Add target to Button in Swift

旧巷老猫 提交于 2020-05-15 08:44:06
问题 I want to implement different targets in different cases to a button. If its the own profile of the current user, the button should add the target "go to settings". If its a different user, I want to add a follow/unfollow action. After checking all parameters, my code should work. But it doesn't work. I added some prints but the button is not clickable. func setupUserInformation(user: UserModel) { usernameLabel.text = user.username if user.uid == UserApi.shared.CURRENT_USER_ID { editButton

Custom circular button for SignIn with Apple

↘锁芯ラ 提交于 2020-04-16 04:53:12
问题 I'm following Apple's guidelines for implementing the "Sign in with Apple" button. In the documentation apple says that it is also possible to use only the logo to create a custom button of "Log in with Apple), also you can also change the shape of the image to have a circular button ... In order to be able to edit the image it also provides insert a mask but I don't understand that we have to create a mask for the button or the selected image. This is what apple wrote in the documentation At