uibutton

how to make UIbutton draggable within UIView?

China☆狼群 提交于 2020-01-01 11:34:30
问题 I need to drag and drop the button in my dash board i can drag and drop the button using the following code - (void)viewDidLoad { [super viewDidLoad]; [eventButton addTarget:self action:@selector(draggedOut:withEvent:)forControlEvents:UIControlEventTouchDragOutside |UIControlEventTouchDragInside]; } - (void) draggedOut: (UIControl *) c withEvent: (UIEvent *) ev { CGPoint point = [[[ev allTouches] anyObject] locationInView:self.view]; if(point.y > 22 && point.y <300) c.center = CGPointMake(237

How to get the X and Y position of a UI button iPhone

杀马特。学长 韩版系。学妹 提交于 2020-01-01 09:27:44
问题 Could somebody show me how to get the x and y position of a UIButton in cocoa? The button moves on the screen when clicked and I want to use it's current position to position another UIBUtton relative to it. I've tried using CGRect rect=[myButton imageRectForContentRect]; The compiler tells me that myButton may not respond to imageRectForContentRect. 回答1: Use myButton.frame Specifically for position, use myButton.frame.origin.x and myButton.frame.origin.y. That would be the top left corner.

UIButton Default Title Color iOS7

左心房为你撑大大i 提交于 2020-01-01 09:19:04
问题 I want to know how to change the Title Colour of a UIButton back to the default value. I have a button that I change the title colour to indicate a something is on, like this; [cell.offStateSwitch setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; Then when it is off, I want to change it back to the default colour. I cant figure out how to get the default system colour for a UIButton. I have found lots of people doing this by forcing a particular RGB value, but that is not

Xcode 8 - Some buttons border removed

怎甘沉沦 提交于 2020-01-01 09:11:54
问题 I just updated my Xcode ver from 7.3 to 8.0 and some buttons borders disappeared. The code looks fine, so I really don't know what happened to the layers. btw - in some other controllers I can see the layers borders. self.button.layer.borderColor = borderColor.CGColor; self.button.layer.borderWidth = 2; self.button.layer.cornerRadius = CGRectGetHeight(self.button.frame) / 2; before: (The image is only for example - the borders looks different at real time) now: 回答1: The reason is that XCode 8

UIButton: Need a circle hit area

杀马特。学长 韩版系。学妹 提交于 2020-01-01 06:54:48
问题 Ok I have 6 custom UIButtons. Their normal state image are all circles images. They are all spaced out equally but all the circles touch each other. The problem with the custom UIbutton (which has a circle image on it), is that the hit area of that button is square, and the corners of this square overlaps the hitarea of the other custom button's hitarea. How do i make the hit area of a UIbutton whos normal state has a circle image, be only clickable on that circle only, rather than the normal

UIButton underneath grouped table view

纵饮孤独 提交于 2020-01-01 06:54:13
问题 Basically, I want to create a button underneath a grouped table view, like contacts.app has to delete contacts. I can create the button fine, I'm just a bit puzzled as to how to decide where to put it. I thought I could just do: CGRect bounds = [[self tableView] bounds]; Then place the button based on that. However, when accessing the size.height of bounds I get zero! Is there a dynamic way to retrieve the tableView's height that I could be missing? Any help is greatly appreciated. Rich 回答1:

Snapchat like buttons over different view controllers

点点圈 提交于 2020-01-01 06:26:09
问题 The 3 main snapchat buttons are on the bottom on the screen, but as you swipe and move between different view controllers, they stay in the same position. Not only that, they also shrink and grow depending on which view you are in. I'm trying to do something similar. I have a button at the top of my vc, and when I segue to another one I would like it to stay it there and still be functional. 回答1: One possible way of going about this would be using a UIPageViewController and setting it up to

how to make button round with image background in IPhone?

戏子无情 提交于 2020-01-01 06:14:25
问题 I have a round button, but i will make it have a backgroud with image. but when i do it, by setting the (what) property to an image, the button becomes rectangle because the image is a rectangle. How do I keep the button round? 回答1: Simply by doing this #import <QuartzCore/QuartzCore.h> myButton.layer.cornerRadius = 8; 回答2: Tested Code: .h -(void)vijayWithApple; .m -(void)vijayWithApple{ NSLog(@"vijayWithApple Called"); } UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

UIButton not working correctly in iOS 7

只愿长相守 提交于 2020-01-01 04:52:26
问题 I have a problem with a UIButton that works perfectly well in iOS6, but fails to respond to touch events in iOS7 up to a certain point. To clarify please see below image: The button that fails is the "Discard All" button that is in the UIView. (Please note, this button is only disabled temporarily and that is NOT the issue. I just don't have a screenshot of the newest test where the button is enabled") This button ignores all touches, unless one first presses the "Discard" or "Retry" buttons

iOS UIButton - Difference between UIButton setUserInteractionEnabled and setEnabled

此生再无相见时 提交于 2020-01-01 04:40:06
问题 Wait!!!: I know that you may think this question have been asked and answered several time before. But I can guarantee you that this question is unique. Question: In an iOS App, just imagine two buttons are there, like shown in the image bellow, and they have two actions which behaves like a toggling logic. And it's logic may be as follows: - (IBAction)testBtnClicked:(id)sender { if ([self.testBtn isEnabled]) { [self.testBtn setEnabled:NO]; [self.setInteractionBtn setUserInteractionEnabled