<bdo id='ve1Dy'></bdo><ul id='ve1Dy'></ul>

      <i id='ve1Dy'><tr id='ve1Dy'><dt id='ve1Dy'><q id='ve1Dy'><span id='ve1Dy'><b id='ve1Dy'><form id='ve1Dy'><ins id='ve1Dy'></ins><ul id='ve1Dy'></ul><sub id='ve1Dy'></sub></form><legend id='ve1Dy'></legend><bdo id='ve1Dy'><pre id='ve1Dy'><center id='ve1Dy'></center></pre></bdo></b><th id='ve1Dy'></th></span></q></dt></tr></i><div id='ve1Dy'><tfoot id='ve1Dy'></tfoot><dl id='ve1Dy'><fieldset id='ve1Dy'></fieldset></dl></div>

      <legend id='ve1Dy'><style id='ve1Dy'><dir id='ve1Dy'><q id='ve1Dy'></q></dir></style></legend>
    1. <small id='ve1Dy'></small><noframes id='ve1Dy'>

      <tfoot id='ve1Dy'></tfoot>
    2. CALayer IOS上的自动布局约束

      时间:2023-09-11
    3. <small id='Uv0jP'></small><noframes id='Uv0jP'>

    4. <i id='Uv0jP'><tr id='Uv0jP'><dt id='Uv0jP'><q id='Uv0jP'><span id='Uv0jP'><b id='Uv0jP'><form id='Uv0jP'><ins id='Uv0jP'></ins><ul id='Uv0jP'></ul><sub id='Uv0jP'></sub></form><legend id='Uv0jP'></legend><bdo id='Uv0jP'><pre id='Uv0jP'><center id='Uv0jP'></center></pre></bdo></b><th id='Uv0jP'></th></span></q></dt></tr></i><div id='Uv0jP'><tfoot id='Uv0jP'></tfoot><dl id='Uv0jP'><fieldset id='Uv0jP'></fieldset></dl></div>
        <tbody id='Uv0jP'></tbody>

      <tfoot id='Uv0jP'></tfoot>
      <legend id='Uv0jP'><style id='Uv0jP'><dir id='Uv0jP'><q id='Uv0jP'></q></dir></style></legend>
        <bdo id='Uv0jP'></bdo><ul id='Uv0jP'></ul>

                本文介绍了CALayer IOS上的自动布局约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                您好,我正在开发 iPhone 应用程序,我在其中尝试为 edittext 设置一侧边框.我是通过以下方式做到的:

                Hi I am developing iPhone application in which I tried to set one side border for edittext. I did this in following way:

                 int borderWidth = 1;
                CALayer *leftBorder = [CALayer layer];
                
                leftBorder.borderColor = [UIColor whiteColor].CGColor;
                leftBorder.borderWidth = borderWidth;
                
                leftBorder.frame = CGRectMake(0, textField.frame.size.height - borderWidth, textField
                                              .frame.size.width, borderWidth);
                [textField.layer addSublayer:leftBorder];
                

                我在 IB 中对我的 edittext 设置了一些限制,这样当我旋转我的设备时,它会据此调整文本字段的宽度.我的问题是调整edittext的宽度而不是调整我为编辑文本设置的CALayer的宽度.所以我想我也必须为我的 CALayer 项目设置一些限制.但我不知道该怎么做.任何人都知道这件事吗?需要帮忙.谢谢.

                I put some constraints on my edittext in IB so that when I rotate my device it will adjust width of text field according to that. My problem is that adjusts the width of edittext not adjusting the width of CALayer which I set for my edit text. So I think I have to put some constraints for my CALayer item as well. But I dont know how to do that. ANy one knows about this? Need Help. Thank you.

                推荐答案

                整个自动调整大小业务是特定于视图的.图层不会自动调整大小.

                the whole autoresizing business is view-specific. layers don't autoresize.

                你必须做的——在代码中——是自己调整层的大小

                what you have to do -- in code -- is to resize the layer yourself

                例如

                在 viewController 中你会这样做

                in a viewController you would do

                - (void) viewDidLayoutSubviews {
                  [super viewDidLayoutSubviews]; //if you want superclass's behaviour... 
                  // resize your layers based on the view's new frame
                  self.editViewBorderLayer.frame = self.editView.bounds;
                }
                

                或者在你可以使用的自定义 UIView 中

                or in a custom UIView you could use

                - (void)layoutSubviews {
                  [super layoutSubviews]; //if you want superclass's behaviour...  (and lay outing of children)
                  // resize your layers based on the view's new frame
                  layer.frame = self.bounds;
                }
                

                这篇关于CALayer IOS上的自动布局约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:UITableView 内的动态 UIImageView 大小 下一篇:自动布局以保持视图大小成比例

                相关文章

              1. <i id='ivVJv'><tr id='ivVJv'><dt id='ivVJv'><q id='ivVJv'><span id='ivVJv'><b id='ivVJv'><form id='ivVJv'><ins id='ivVJv'></ins><ul id='ivVJv'></ul><sub id='ivVJv'></sub></form><legend id='ivVJv'></legend><bdo id='ivVJv'><pre id='ivVJv'><center id='ivVJv'></center></pre></bdo></b><th id='ivVJv'></th></span></q></dt></tr></i><div id='ivVJv'><tfoot id='ivVJv'></tfoot><dl id='ivVJv'><fieldset id='ivVJv'></fieldset></dl></div>
              2. <legend id='ivVJv'><style id='ivVJv'><dir id='ivVJv'><q id='ivVJv'></q></dir></style></legend>

                  <small id='ivVJv'></small><noframes id='ivVJv'>

                  <tfoot id='ivVJv'></tfoot>
                  • <bdo id='ivVJv'></bdo><ul id='ivVJv'></ul>