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 8528243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:45:31+00:00 2026-06-11T08:45:31+00:00

I created a UIView Subclass and are using drawing rounded rects with UIBezierpath and

  • 0

I created a UIView Subclass and are using drawing rounded rects with UIBezierpath and fill it with some gradient.

In short this is what the subclass draw rect looks like:

CGRect frame1 = //size of Frame 1

CGRect frame2 = //size of Frame 2



//gradientingStart
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

if (options == false) {
    self.color = [self createRandomColor];
}



NSArray *gradientColors = [NSArray arrayWithObjects:
                           (id)[UIColor colorWithHue:color saturation:saturationVal brightness:brightnessVal alpha:1].CGColor,
                           (id)[UIColor colorWithHue:color+0.04 saturation:saturationVal+0.15 brightness:brightnessVal-0.15 alpha:1].CGColor, nil];

CGFloat gradientLocations2[] = {0.25,1};
CGGradientRef gradient2 = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)gradientColors, gradientLocations2);
CGContextSaveGState(context);
//gradientingEnd

UIBezierPath *result =
[UIBezierPath bezierPathWithRoundedRect: frame1 cornerRadius:radius];
[result appendPath:
 [UIBezierPath bezierPathWithRoundedRect: frame2 cornerRadius:radius]];
[result setLineWidth:3];
[[UIColor blackColor]setStroke];
[result stroke];
[result fill];
[result addClip];
CGContextDrawLinearGradient(context, gradient2, CGPointMake(0, 0), CGPointMake(0, self.bounds.size.height), 0);

//important to prevent leaks
CGGradientRelease(gradient2);
CGColorSpaceRelease(colorSpace);
//-------
UIImage *texture = [UIImage imageNamed:@"texture2.png"];
[texture drawInRect:CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, self.bounds.size.height)];

Now I’m creating several instances of this in my view controller and trying the move them with animations like this:

[UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
    costumview.alpha = 0;
    [costumview setFrame:CGRectMake(320,0,320,420)];
    [self reorderViewsFrom:costumview.intValue];
    overlay.alpha = 0;
}completion:^(BOOL finished){
}];

But unfortunately the animation is on a device very laggy and the more (5-10) costum views are display the worse it gets.

How can i improve the performance and provide smooth animations? I think changing the costum view is not an alternative because this would destroy the sense of the application. Are there any faster ways to animate the costum view?

  • 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-06-11T08:45:32+00:00Added an answer on June 11, 2026 at 8:45 am

    I pointed out that using some CALayer transformation (rounding corners) causing the lag – unfournately this wasn’t in the snippet I posted.

    I avoided it by creating the rounded corners with a own uiview subclass. This makes the app a lot smoother. All these rasterization stuff didn’t do it for me…

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

Sidebar

Related Questions

I created a subclass of UIView that overrides drawRect: and uses AddArcToPoint() to draw
I created a UIView subclass associated with .xib file. This UIView subclass is to
I am trying to draw an image into a UIView subclass overriding drawRect. This
I created a subclass from UIView #import <UIKit/UIKit.h> @interface MeeSelectDropDownView : UIView { UILabel
I'm using a rotation animation created with CABasicAnimation . It rotates a UIView over
I've created a subclass of UIView called Status which is designed to display a
i need to draw two lines. can i use the same UIView subclass to
I found some great code that is a subclass of UIView which draws that
I created a subclass of UIView and within the subclass I try to access
I have created a custom subclass of UIView for an interface element that I

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.