Position View Within View At Percentage Point Swift

Okay, let's talk Swift. And specifically, let’s wrestle with something that's caused me more head-scratching than a chimpanzee with a Rubik's Cube: positioning views inside other views...at percentage points.
We've all been there. You've got your lovely parent view. You want a little subview to hang out, say, precisely 20% across and 30% down. Sounds reasonable, right? Famous last words.
Because that's when the fun really begins.
Must Read
First, you think, "Aha! Constraints! Anchors! I've got this!" You wrangle with NSLayoutConstraint, trying to multiply the parent's width and height by your desired percentages. You might even feel a flicker of pride when the code compiles. Don't get too cocky.
Then you run it. And your subview is…somewhere. Maybe vaguely in the right direction. Possibly orbiting your parent view like a lost satellite. Definitely not where you painstakingly calculated it should be.
Let's be honest, constraints are great for many things. But directly translating percentages into constraints feels like trying to herd cats with a laser pointer.

So, what’s the alternative? Maybe you bravely dive into the world of CGRect and manual frame calculations. You grab the parent's frame, do some math involving your magical percentages, and finally, finally, assign that frame to your subview.
This…usually works. Mostly. Until your parent view decides to resize itself. Then your carefully crafted masterpiece becomes a pixelated mess. You have to listen to layout changes and recalculate, feeling like Sisyphus pushing that boulder up a mountain again.
The Unpopular Opinion (Brace Yourselves)
Here it comes: I think sometimes, just sometimes, a teensy bit of code that directly calculates positions based on percentage is…dare I say…simpler than the constraint gymnastics or the endless frame recalculations.

Don't throw your iPhones at me! I'm not saying ditch constraints entirely. They're vital! I'm just suggesting that when you have a simple, static layout requirement—a view always nestled 25% from the top and 10% from the left, for example—maybe, just maybe, a little direct calculation isn't the worst thing in the world.
It's like using a butter knife to spread butter. Sometimes, the specialized butter-spreading tool (constraints?) is overkill. The knife (direct calculation?) gets the job done perfectly well.
Okay, I’m ready for the hate mail. But before you send it, consider this: have you ever spent an hour debugging a constraint that stubbornly refused to position your view where you wanted it? Have you ever felt the sweet, fleeting joy of seeing your percentage-based layout actually…work?

I suspect I'm not alone. We've all had those moments where we've stared blankly at the screen, wondering if there's a secret, arcane ritual required to properly use Auto Layout.
Perhaps the real answer is a smarter, more intuitive way to express percentage-based layouts in Swift. Something that sits between the rigidity of constraints and the manual labor of frame calculations. Until then, I'll keep wrestling with my constraints…and occasionally, sneaking in a little bit of direct calculation when nobody's looking.
And let's be real, the Container View doesn't always play nice with these percentage shenanigans either! It's like adding another layer of abstraction just to make things more confusing. Anyone else feel my pain?

So, next time you're wrestling with positioning a view at a percentage point, remember this article. Maybe, just maybe, a little direct calculation is your secret weapon. Just don't tell anyone I said that.
Okay, I’m diving back into my code now. Wish me luck!
