Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:00:23+00:00 2026-05-15T20:00:23+00:00

I do this quite a bit in my code: self.sliderOne.frame = CGRectMake(newX, 0, self.sliderOne.frame.size.width,

  • 0

I do this quite a bit in my code:

self.sliderOne.frame  = CGRectMake(newX, 0, self.sliderOne.frame.size.width, self.sliderOne.frame.size.height); 

Is there any way to avoid this tedious code? I have tried this type of thing:

self.sliderOne.frame.origin.x = newX;

but I get a Lvalue required as left operand of assignment error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:00:23+00:00Added an answer on May 15, 2026 at 8:00 pm

    I finally followed @Dave DeLong’s suggestion and made a category. All you have to do is import it in any class that wants to take advantage of it.

    UIView+AlterFrame.h

    #import <UIKit/UIKit.h>
    
    @interface UIView (AlterFrame)
    
    - (void) setFrameWidth:(CGFloat)newWidth;
    - (void) setFrameHeight:(CGFloat)newHeight;
    - (void) setFrameOriginX:(CGFloat)newX;
    - (void) setFrameOriginY:(CGFloat)newY;
    
    @end
    

    UIView+AlterFrame.m

    #import "UIView+AlterFrame.h"
    
    @implementation UIView (AlterFrame)
    
        - (void) setFrameWidth:(CGFloat)newWidth {
            CGRect f = self.frame;
            f.size.width = newWidth;
            self.frame = f;
        }
    
        - (void) setFrameHeight:(CGFloat)newHeight {
            CGRect f = self.frame;
            f.size.height = newHeight;
            self.frame = f;
        }
    
        - (void) setFrameOriginX:(CGFloat)newX {
            CGRect f = self.frame;
            f.origin.x = newX;
            self.frame = f;
        }
    
        - (void) setFrameOriginY:(CGFloat)newY {
            CGRect f = self.frame;
            f.origin.y = newY;
            self.frame = f;
        }
    
    @end
    

    I could DRY up the methods using blocks… I’ll do that at some point soon, I hope.

    Later: I just noticed CGRectOffset and CGRectInset, so this category could be cleaned up a bit (if not eliminated altogether).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should reduce the executable size quite a bit in some of my very
Right this is confusing me quite a bit, i'm not sure if any of
Aren't i doing this the standard way? I see this format quite a bit
I've edited this quite a bit and bolded my question at this point. I
I've done quite a bit of googling on this error but have had no
I've searched around quite a bit for ways to do this and I finally
I noticed people wrote about this circular reference problem quite a bit before but
I've been struggling a bit with this tiny problem - and I'm quite sure
I've heard this quite a bit when it comes to TDD, You should always
I have actually seen this question quite a bit here, but none of them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.