A standalone Mac/iPhone port of the TTStyle and TTShape classes from the Three20 project
Objective-C C
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Demos iPhone demo works again Mar 27, 2010
Screenshots Added screenshots Nov 6, 2009
Source Removed PPC support for Mac App Store Jul 13, 2011
.gitignore Updated gitignore Jul 3, 2011
README.md Updated README.md Jan 14, 2010



VillainousStyle is a drawing library for defining a visual style from a chain of individual drawing instructions. Each instruction modifies the drawing context to perform common operations; such operations include shadows, fills, borders, and shapes. It allows for multiple style sheets which can be used to theme an application in multiple visual contexts. VillainousStyle sits on top of CoreGraphics, and does not use WebKit for rendering at all. It is a fork of the VSStyle and VSShape classes, originally from the Three20 project.

The project contains two targets:

  • the VillainousStyle framework, which can be included in your application
  • the MacDemo application, which demonstrates how to use the framework, including multiple stylesheets


  • Mac OS X 10.5+
  • 32-bit only currently (mostly because it hasn't been fully tested in 64-bit)


Clone or download the repository, and build the framework. You can also build and run the test application.


VSStyleSheet is an abstract superclass for a set of styles. Subclass it and add methods for each style you wish to add. You will likely want to create a protocol for your styles to implement, to ensure that your stylesheet implements all the necessary styles.

There is a global stylesheet, which can be thought of as the "active" stylesheet. Call +[VSStyleSheet setGlobalStyleSheet:] to change the active theme, which will fire a VSStyleSheetChangedNotification. When that gets fired, you'll want to tell your views to update their styles and redraw.


Styles affect drawing and positioning. Most will affect the next VSStyle objects in the chain.

  • Fills
  • VSSolidFillStyle - Fills the current shape with a solid color
  • VSLinearGradientFillStyle - Fills the current shape with a gradient between two colors
  • VSReflectiveFillStyle - Fills the current shape with a glossy-style gradient between two colors
  • Borders
  • VSSolidBorderStyle - Draws a border around the current shape with a solid color
  • VSBevelBorderStyle - Draws a beveled edge border for a 3D effect around the current shape
  • VSFourBorderStyle - Draws a border around the current shape with four colors, one for each edge
  • Shadows
  • VSShadowStyle - Draws a shadow behind content with a given color, blur, and offset
  • VSInnerShadowStyle - Draws a shadow inside the content with a given color, blur, and offset
  • Positioning
  • VSBoxStyle - Adds a margin or padding to the content area
  • VSInsetStyle - Adds edge insets to the content area
  • Content
  • VSTextStyle - Draws text inside the current shape (see VSStyleDelegate)
  • VSImageStyle - Draws an image inside the current shape (see VSStyleDelegate)
  • VSContentStyle - Calls a delegate method to draw arbitrary content (see VSStyleDelegate)
  • Clipping
  • VSMaskStyle - Clips the drawing area to an image mask
  • VSShapeStyle - Clips the drawing area with a VSShape object


Shapes affect the fills and borders, but do not clip the content styles.

  • VSRectangleShape
  • VSRoundedRectangleShape
  • VSRoundedLeftArrowShape - a rounded rectangle with a left-facing arrow
  • VSRoundedRightArrowShape - a rounded rectangle with a right-facing arrow

Future Ideas

  • iPhone static library
  • Cappuccino library
  • File-based stylesheets that can be read/written from VSStyleSheet objects
  • GUI builder for styles
  • More styles!


Light Test Style Dark Test Style


Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.