• XCode5 使用AutoLayout情况下改变控件的 方法


    [self.viewButtonsetTranslatesAutoresizingMaskIntoConstraints:NO];

        //[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.viewButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];

        //改变 高度

        [self.viewaddConstraint:[NSLayoutConstraint

                                  constraintWithItem:self.viewButton

                                  attribute:NSLayoutAttributeHeight

                                  relatedBy:NSLayoutRelationEqual

                                  toItem:self.view

                                  attribute:NSLayoutAttributeHeight

                                  multiplier:0.3

                                  constant:0]];

        [self.viewButtonaddObserver:selfforKeyPath:@"bounds"options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitialcontext:nil];//注册kvo监听bounds的变化

        

    }

    //kvo回调

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

    {

        if (object == self.viewButton && [keyPath isEqualToString:@"bounds"])

        {

    //        [self.viewButton setTitle:NSStringFromCGSize(self.viewButton.bounds.size) forState:UIControlStateNormal];

            

            NSLog(@"");

        }

    }

  • 相关阅读:
    LeetCode-018-四数之和
    LeetCode-017-电话号码的字母组合
    LeetCode-016-最接近的三数之和
    LeetCode-015-三数之和
    LeetCode-014-最长公共前缀
    LeetCode-013-罗马数字转整数
    LeetCode-012-整数转罗马数字
    LeetCode-011-盛最多水的容器
    LeetCode-010-正则表达式匹配
    [leetcode]103. Binary Tree Zigzag Level Order Traversal二叉树Z形遍历
  • 原文地址:https://www.cnblogs.com/chenhaosuibi/p/3520304.html
Copyright © 2020-2023  润新知