autolayout

SnapKit: How to set layout constraints for items in a TableViewCell programatically

人走茶凉 提交于 2019-12-24 04:43:12
问题 I'm a beginner at swift/iOS dev. Coming from web dev, the layout model is completely confusing to me compared to the DOM/Box model. I know it means just getting one's head around everything, but for the life of me I just can't seem to figure it out, I was hoping a basic example like so might help illustrate a few things, even as I am using a DSL like snapkit: http://snapkit.io/ How could I go about building the constraints for a layout like the following: What I have so far, which is -clearly

auto layout leading or trainling -16

点点圈 提交于 2019-12-24 03:25:56
问题 If I just drag a View to occupy all the available screen, when I tried to set auto layout leading and trailing space, it is always saying -16, I am thinking shouldn't it be 0 to the left/right edges? If I set to 0, actually the view will shrink horizontally by 16 for left and 16 for right. I am a little confused, why there is a 16 difference? 回答1: When you first add UIView in your super View. and set constrain default leading and trailing is -16 as below image. deselect on constrain to

Get variable height for a UIButton for iPhones 5/6/6+

泄露秘密 提交于 2019-12-24 02:18:15
问题 For my 1) portrait only 2) deployment target iOS7/iOS8 app, I have in my design UIButtons which have variable heights, for iPhone 5, iPhone 6 and iPhone 6+. I am trying to use auto layout for this. (Not using size classes though). Using auto layout how can I specify variable height for UIButton for these 3 screen sizes. The buttons look fine on iPhones 5* models, but thinner on iphone 6/6+. Now in auto layout I can say height >= or = or <= say 55), but how do I specify 44 for iphone5, 55 for

How to make a custom view's frame match its instrinsic content size

本小妞迷上赌 提交于 2019-12-24 01:47:05
问题 Custom Label that Resizes According to its Contents I'm making a label from scratch. (My end purpose is to make a vertical text label for Mongolian script, but for now I am just making a normal horizontal text label as practice.) As long as there are no length and width constraints, I want my custom label's frame to resize according to its intrinsic content size. It Works in IB In IB everything seems to be working fine when I test a UILabel , my custom label (a UIView subclass), and a button.

RTL (Right-to-left) via auto layout broken on iOS 6.1 / iOS 7.0?

不羁岁月 提交于 2019-12-24 01:25:33
问题 can it be that the RTL concept using auto layout is not working on iOS 6.1 and iOS 7.0 devices (also simulator) anymore? It is working for the iOS 6.0 (have only the simulator to check with) - so when setting the device language to Arabic, it mirrors the UI as expected for the 6.0 version. (The Direction for the horizontal constraint is set to: "Leading to Trailing") Have googled this issue for days, but without success... Thanks for any help! 回答1: Ok. Seems that iOS 6.1+ devices (simulator)

UILabel inside nested UIStackViews inside UITableViewCell sometimes truncating

天涯浪子 提交于 2019-12-24 00:59:12
问题 I have a tableview cell in one of my tables setup as containing the following view hierarchy The outer horizontal stackview is pinned to the cell's content view on trailing, leading, bottom and top edges. The right label is pinned to its parent stackViewHackView on trailing, leading, bottom and top edges Within my controllers code I've got the cells setup to be dynamic height to fit the content of the cells so they can grow or shrink depending on the content size tableView.rowHeight =

Using a Timer in the background thread to update UI

↘锁芯ラ 提交于 2019-12-24 00:53:48
问题 In my app I have a timer that can be up to 5 minutes long. The user can add an element to an array which resets the timer to 5 minutes. When the timer counts town, there's also a UIView which changes its width from 100% of the view to 0% of it in proportion to the timer. I'd like to run my timer on a background thread to avoid a delay in the timer starting due to other UI events happening. Is it possible to have a timer run in a background thread whose associated function that the timer calls

How to align UILabel Horizontally with the profile photo image?

拈花ヽ惹草 提交于 2019-12-24 00:38:55
问题 I have to show the Name and EmailID aligned horizontally properly with the Profile Image . So that the Name and email ID appears exactlybat the center of the UIImageView. But you can see the name and email id are not in centre with the profile image. Why is this happening? I have given the following constraints: 回答1: Remove leading and trailing Constrain and set align center x to imageView. You can also set leading and trailing Constrain. but both are equal as follow. 回答2: Just control+drag

Autolayout and proportional positioning

我是研究僧i 提交于 2019-12-23 21:05:56
问题 I suppose that my situation should be a common problem, but I'm really new to AutoLayout and to me it seems particularly complicated: I want to make a layout to be suitable with 3.5 inches and 4 inches screens. This is the view for 4 inches displays: And here is the view for a 3.5 inches display: What I need is essentially make the spaces between the segmented control and the yellow and blue view proportional to the screen size I suppose. My solution (that doesn't work): 1)Adding constraints

Which is the best approach among Autolayout or calculating the height using NSAttributedString, to implement dynamic height of an UITableViewCell?

拥有回忆 提交于 2019-12-23 19:13:04
问题 I have followed the tutorial from http://raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout and implemented the same, but with the release of iOS 8.3, the above tutorial doesn't seem to be working. Therefore i switched back to the following code which works absolutely fine -(float)height :(NSMutableAttributedString*)string { NSAttributedString *attributedText = string; CGRect rect = [attributedText boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options: