Cover image
Try Now
2013-08-06

Progress view with custom images

3 years

Works with Finder

8

Github Watches

15

Github Forks

71

Github Stars

MCProgressBarView

Progress bar view with custom images.

Sample

Installation

  1. Add the QuartzCore framework to your project;
  2. Copy files from the 'Classes' folder into your project.

Usage

You will first need to create custom images for background and foreground or copy the ones coming with this project to your project.

#import "MCProgressBarView.h"

Initialize the images:

UIImage * backgroundImage = [[UIImage imageNamed:@"progress-bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
UIImage * foregroundImage = [[UIImage imageNamed:@"progress-fg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];

Notice the [UIImage -resizableImageWithCapInsets:] call. You can read more about it in the documnetation for this method. Essentiually, it defines which parts of the image will not be stretched when image is resized. Here, it's used to mark the left and the right edges.

Create the view and add it to the view hierarchy:

MCProgressBarView * _progressBarView = [[MCProgressBarView alloc] initWithFrame:CGRectMake(25, 100, 270, 20)
	backgroundImage:backgroundImage
	foregroundImage:foregroundImage];
	
[self.view addSubview:_progressBarView];

Now, the progress you set (in the range of 0.0 to 1.0), will be reflected in the component:

_progressBarView.progress = 0.25;

offsetForZero

Matt Curtis pointed out that when progress is 0.0, there is still some initial progress indicator shown (see the image above). After some consideration, I've decided that there are situations when that is desirable and some situations when no progress should be shown. To address this, a new property has been added:

@property (nonatomic, assign) CGFloat offsetForZero;

The default value of this property is the sum of the left and the right cap inset for the foreground image. To "taper off" the initial size of the progress indicator, you can set it to a lower value. For the images in the sample project, that value can be set to 10.0:

progressBarView.offsetForZero = 10.0;

See the sample image above to see the effect. That value can vary depending on the images you use in your project.

License

Code in this project is available under the MIT license.

相关推荐

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 田中 楓太
  • A virtual science instructor for engaging and informative lessons.

  • https://thisdifference.com
  • Friendly, engaging chat companion

  • 1Panel-dev
  • 💬 MaxKB is a ready-to-use AI chatbot that integrates Retrieval-Augmented Generation (RAG) pipelines, supports robust workflows, and provides advanced MCP tool-use capabilities.

  • GLips
  • MCP server to provide Figma layout information to AI coding agents like Cursor

  • Dhravya
  • Collection of apple-native tools for the model context protocol.

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

  • adafruit
  • Python code to use the MCP3008 analog to digital converter with a Raspberry Pi or BeagleBone black.

  • activepieces
  • AI Agents & MCPs & AI Workflow Automation • (280+ MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

  • open-webui
  • A simple, secure MCP-to-OpenAPI proxy server

    Reviews

    2 (1)
    Avatar
    user_ZVIHPlLD
    2025-04-17

    MCProgressView by Baglan is an amazing tool for tracking progress in any app. This utility is straightforward, easy to integrate, and highly customizable, making it suitable for various applications. The user-friendly design simplifies the implementation process, ensuring a seamless experience. Highly recommend checking out MCProgressView for anyone looking to enhance their app's progress tracking capabilities. Great job, Baglan!