I am a beginner in objective c. I am trying to design a UIButton so that it's left side is always touches left side of screen and right side of UIButton should always be on centre of screen. I am trying it on storyboard with auto layout, but when I rotate the screen means UIButton doesn't meet the condition. What constraint should I have to use for this?
How to place UiButton's right side is always on centre of screen?
165 Views Asked by e.k At
1
There are 1 best solutions below
Related Questions in IOS
- Overlapping UICollectionView in storyboard
- Cannot pod spec lint because of undeclared type errors
- Is the transactionReceipt data present in dataWithContentsOfURL?
- UIWebView Screen Fitting Issue
- ZXingObjC encoding issues
- iOS: None of the valid provisioning profiles allowed the specific entitlements
- How to hide "Now playing url" in control center
- CloudKit: Preventing Duplicate Records
- Slow performance on ipad erasing image
- Swift code with multiple NSDateFormatter - optimization
- iOS 8.3 Safari crashes on input type=file
- TTTTimeIntervalFormatter always returns strings in English
- How do I add multiple in app purchases in Swift Spritekit?
- Setup code for xibs in iOS. -awakFromNb:
- iOS Voice Over only reads out the title of any alert views
Related Questions in UIBUTTON
- Image and Text locations in UIButton
- How to change position of UIButton?
- Set Background Color on UIButton when Disabled?
- Checking UIButton Image
- If statements for code generated buttons, Swift
- Trouble using UiButton as toggle switch
- Mutable global methods?
- Will handling UIButton touch event inside a UITableViewCell subclass violate MVC?
- Setting frame for UIButton ignored
- UIStackView Layout
- How to vertically center two views & divide the width equally relative to the super view?
- Multiple Buttons, But only one pressed at a time
- Customize the UIButton resize according to text length and place UILabel after that
- UITableViewCell reload selected image with pattern image
- Calling prepareforSegue from a UIButton?
Related Questions in IOS-AUTOLAYOUT
- Animate Layout Changes inside UICollectionViewCell and it's subviews having AutoLayout constraints
- Auto layout of a Child Container that embeds a UIViewController
- Auto Layout Issues iOS
- Why my UILabel 's AutoLayout not working
- How to achieve this layout with auto layout ?
- Xcode 8.1 Still has Autolayout issue in Storyboard
- How we can increase width of two button when we remove third button from view
- How to place UiButton's right side is always on centre of screen?
- View Inside scroll view shifts down
- Compare adding constraints in autolayout Vs setting autoresizing in IB Inspector
- How to efficiently use Autolayut and Auto-Resizing in same target?
- Top space on device rotation
- How to position top in iOS swift?
- UITableView with self sizing cells becomes jerky when calling deleteRowsAtIndexPaths
- What advantages does SnapKit have over using autolayout in Interface Builder?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Setting up constraint is not so simple as it seems, you can achieve more with constraints too. From your question i understood that you want UIButton from left side screen to cover half screen. To do so: 1) Add left margin constraint with constant 0(zero), this will start your button from left side of the screen. Now, how to make UIButton to fill half of the screen, You have to add little logic in you constraint. button with to the centre of screen =
screen.width/2Here is how you can achieve with constraints.1)Right Click on Button, drag to main view, 2)From list Select Equal width, Usually this will makes your button same size of main view. 3)Select the width constraint of button (Must be in red Color) 4)Go to property inspector of constraint, 5) In multiplier filed change 1 to 0.5. This is how you can make your button half size of screen.