ui_util.mm 987 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #import <UIKit/UIKit.h>
  5. #include "ios/chrome/share_extension/ui_util.h"
  6. #if !defined(__has_feature) || !__has_feature(objc_arc)
  7. #error "This file requires ARC support."
  8. #endif
  9. namespace ui_util {
  10. const CGFloat kAnimationDuration = 0.3;
  11. CGFloat AlignValueToPixel(CGFloat value) {
  12. CGFloat scale = [[UIScreen mainScreen] scale];
  13. return floor(value * scale) / scale;
  14. }
  15. void ConstrainAllSidesOfViewToView(UIView* container, UIView* filler) {
  16. [NSLayoutConstraint activateConstraints:@[
  17. [filler.leadingAnchor constraintEqualToAnchor:container.leadingAnchor],
  18. [filler.trailingAnchor constraintEqualToAnchor:container.trailingAnchor],
  19. [filler.topAnchor constraintEqualToAnchor:container.topAnchor],
  20. [filler.bottomAnchor constraintEqualToAnchor:container.bottomAnchor],
  21. ]];
  22. }
  23. } // namespace ui_util