Giter Site home page Giter Site logo

Comments (4)

joshaber avatar joshaber commented on April 28, 2024

Yep, that should probably exist.

from reactivecocoalayout.

jspahrsummers avatar jspahrsummers commented on April 28, 2024

I don't think so. Setting center is notoriously error-prone. There are two specific problems with it in RCL:

  1. It's really easy for views to end up on half pixels. rcl_bounds and rcl_frame perform automatic alignment of the rectangles they're set to, but it's more difficult to align the center point. If you try to align the center by using the view's entire frame, what happens if the size is modified later in the same run loop iteration? It's just tricky.
  2. RCL very much favors building up a complete frame and setting that in one fell swoop, because weird behaviors can result if different pieces of the frame are set separately.

It's a better idea to just -alignCenter: the desired bounds, so that you have a signal which represents the total layout of the view.

from reactivecocoalayout.

zakdances avatar zakdances commented on April 28, 2024

Isn't the center property of a UIView derived from frame, not from bounds? Will -alignCenter: used on rcl_frame get the desired result even if a transform has been applied to the view (or it's layer)?

If true, then this should work fine.

from reactivecocoalayout.

zakdances avatar zakdances commented on April 28, 2024

So I'm trying this out with code such as

RACSignal *superBoundsMidWidth = self.view.rcl_boundsSignal.centerX;
RACSignal *superBoundsMidHeight = self.view.rcl_boundsSignal.centerY;

RAC(videoPlayer.rcl_frame) = [videoPlayer.rcl_frameSignal alignCenter:[RACSignal pointsWithX:superBoundsMidWidth Y:superBoundsMidHeight]];

and it appears to be working for now. Closing.

from reactivecocoalayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.