Merge pull request #46 from richi/CoreGraphics

Additional CoreGraphics Example
This commit is contained in:
Micha Mettke 2016-02-01 22:50:56 +01:00
commit 6d8f2e4033
5 changed files with 675 additions and 0 deletions

View File

@ -7,6 +7,9 @@
<FileRef
location = "group:iOS_GL_ES.xcodeproj">
</FileRef>
<FileRef
location = "group:iOS_CoreGraphics.xcodeproj">
</FileRef>
<FileRef
location = "group:tvOS_GL_ES.xcodeproj">
</FileRef>

View File

@ -0,0 +1,275 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
50F9C54A1C5FE56C009533F4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F9C5491C5FE56C009533F4 /* main.m */; };
50F9C5611C5FE7BD009533F4 /* zahnrad.c in Sources */ = {isa = PBXBuildFile; fileRef = 50F9C55F1C5FE7BD009533F4 /* zahnrad.c */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
50F9C5451C5FE56C009533F4 /* iOS_CoreGraphics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS_CoreGraphics.app; sourceTree = BUILT_PRODUCTS_DIR; };
50F9C5491C5FE56C009533F4 /* main.m */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; tabWidth = 4; };
50F9C5591C5FE56C009533F4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50F9C55F1C5FE7BD009533F4 /* zahnrad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zahnrad.c; path = ../../../zahnrad.c; sourceTree = "<group>"; };
50F9C5601C5FE7BD009533F4 /* zahnrad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zahnrad.h; path = ../../../zahnrad.h; sourceTree = "<group>"; };
50F9C5621C5FE7D9009533F4 /* demo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = demo.c; path = ../../demo.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
50F9C5421C5FE56C009533F4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
50F9C53C1C5FE56C009533F4 = {
isa = PBXGroup;
children = (
50F9C5471C5FE56C009533F4 /* iOS_CoreGraphics */,
50F9C5461C5FE56C009533F4 /* Products */,
);
sourceTree = "<group>";
};
50F9C5461C5FE56C009533F4 /* Products */ = {
isa = PBXGroup;
children = (
50F9C5451C5FE56C009533F4 /* iOS_CoreGraphics.app */,
);
name = Products;
sourceTree = "<group>";
};
50F9C5471C5FE56C009533F4 /* iOS_CoreGraphics */ = {
isa = PBXGroup;
children = (
50F9C5621C5FE7D9009533F4 /* demo.c */,
50F9C55F1C5FE7BD009533F4 /* zahnrad.c */,
50F9C5601C5FE7BD009533F4 /* zahnrad.h */,
50F9C5491C5FE56C009533F4 /* main.m */,
50F9C5591C5FE56C009533F4 /* Info.plist */,
50F9C5481C5FE56C009533F4 /* Supporting Files */,
);
path = iOS_CoreGraphics;
sourceTree = "<group>";
};
50F9C5481C5FE56C009533F4 /* Supporting Files */ = {
isa = PBXGroup;
children = (
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
50F9C5441C5FE56C009533F4 /* iOS_CoreGraphics */ = {
isa = PBXNativeTarget;
buildConfigurationList = 50F9C55C1C5FE56C009533F4 /* Build configuration list for PBXNativeTarget "iOS_CoreGraphics" */;
buildPhases = (
50F9C5411C5FE56C009533F4 /* Sources */,
50F9C5421C5FE56C009533F4 /* Frameworks */,
50F9C5431C5FE56C009533F4 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = iOS_CoreGraphics;
productName = iOS_CoreGraphics;
productReference = 50F9C5451C5FE56C009533F4 /* iOS_CoreGraphics.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
50F9C53D1C5FE56C009533F4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = richi;
TargetAttributes = {
50F9C5441C5FE56C009533F4 = {
CreatedOnToolsVersion = 7.2;
};
};
};
buildConfigurationList = 50F9C5401C5FE56C009533F4 /* Build configuration list for PBXProject "iOS_CoreGraphics" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 50F9C53C1C5FE56C009533F4;
productRefGroup = 50F9C5461C5FE56C009533F4 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
50F9C5441C5FE56C009533F4 /* iOS_CoreGraphics */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
50F9C5431C5FE56C009533F4 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
50F9C5411C5FE56C009533F4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
50F9C5611C5FE7BD009533F4 /* zahnrad.c in Sources */,
50F9C54A1C5FE56C009533F4 /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
50F9C55A1C5FE56C009533F4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
50F9C55B1C5FE56C009533F4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
50F9C55D1C5FE56C009533F4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
INFOPLIST_FILE = iOS_CoreGraphics/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.richi.iOS-CoreGraphics";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
50F9C55E1C5FE56C009533F4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
INFOPLIST_FILE = iOS_CoreGraphics/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.richi.iOS-CoreGraphics";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
50F9C5401C5FE56C009533F4 /* Build configuration list for PBXProject "iOS_CoreGraphics" */ = {
isa = XCConfigurationList;
buildConfigurations = (
50F9C55A1C5FE56C009533F4 /* Debug */,
50F9C55B1C5FE56C009533F4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
50F9C55C1C5FE56C009533F4 /* Build configuration list for PBXNativeTarget "iOS_CoreGraphics" */ = {
isa = XCConfigurationList;
buildConfigurations = (
50F9C55D1C5FE56C009533F4 /* Debug */,
50F9C55E1C5FE56C009533F4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 50F9C53D1C5FE56C009533F4 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:iOS_CoreGraphics.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIcons</key>
<dict/>
<key>CFBundleIcons~ipad</key>
<dict/>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,340 @@
/*
Copyright (c) 2016 richi
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#import <UIKit/UIKit.h>
#include "zahnrad.h"
#include "../../demo.c"
static void* mem_alloc(zr_handle unused, size_t size)
{
return calloc(1, size);
}
static void mem_free(zr_handle unused, void* ptr)
{
free(ptr);
}
NSString* stringFromZR(const char* text, zr_size len)
{
char cstr[len + 1];
strncpy(cstr, text, len);
cstr[len] = 0;
return [NSString stringWithUTF8String: cstr];
}
static zr_size fontTextWidth(zr_handle handle, float height, const char* text, zr_size len)
{
UIFont* font = (__bridge UIFont*) handle.ptr;
NSString* aString = stringFromZR(text, len);
NSDictionary* attributes = @{ NSFontAttributeName: font};
CGSize stringSize = [aString sizeWithAttributes: attributes];
return ceil(stringSize.width);
}
#pragma mark - ZRView -
@interface ZRView : UIView
{
UIFont* font;
struct zr_user_font usrfnt;
struct zr_allocator alloc;
struct demo gui;
}
@end
@implementation ZRView
- (instancetype) initWithFrame: (CGRect) frame
{
if (!(self = [super initWithFrame: frame]))
return self;
alloc.userdata.ptr = NULL;
alloc.alloc = mem_alloc;
alloc.free = mem_free;
font = [UIFont systemFontOfSize: 11];
font = [UIFont fontWithName: @"Menlo-Regular" size: 11];
NSDictionary* attributes = @{NSFontAttributeName: font};
CGSize stringSize = [@"W" sizeWithAttributes: attributes];
memset(&usrfnt, 0, sizeof(usrfnt));
usrfnt.height = round(stringSize.height);
usrfnt.width = fontTextWidth;
usrfnt.userdata.ptr = (__bridge void*)(font);
zr_init(&gui.ctx, &alloc, &usrfnt);
zr_clear(&gui.ctx);
run_demo(&gui);
return self;
}
#define setColor(_c) \
CGContextSetRGBStrokeColor(context, _c->color.r / 255.0, _c->color.g / 255.0, _c->color.b / 255.0, _c->color.a / 255.0); \
CGContextSetRGBFillColor(context, _c->color.r / 255.0, _c->color.g / 255.0, _c->color.b / 255.0, _c->color.a / 255.0);
- (void) drawRect: (CGRect) rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
UIColor* color = [UIColor blackColor];
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
const struct zr_command* cmd;
CGContextSaveGState(context);
zr_foreach(cmd, &gui.ctx)
{
switch (cmd->type)
{
case ZR_COMMAND_SCISSOR:
{
const struct zr_command_scissor* s = zr_command(scissor, cmd);
CGRect cr = CGRectMake(s->x, s->y, s->w, s->h);
CGContextRestoreGState(context);
CGContextSaveGState(context);
CGContextClipToRect(context, cr);
} break;
case ZR_COMMAND_LINE:
{
const struct zr_command_line* l = zr_command(line, cmd);
setColor(l);
CGContextBeginPath(context);
CGContextMoveToPoint(context, l->begin.x + .5, l->begin.y + .5);
CGContextAddLineToPoint(context, l->end.x + .5, l->end.y + .5);
CGContextStrokePath(context);
} break;
case ZR_COMMAND_RECT:
{
const struct zr_command_rect* r = zr_command(rect, cmd);
CGRect cr = CGRectMake(r->x, r->y, r->w, r->h);
setColor(r);
if (!r->rounding) CGContextFillRect(context, cr);
else
{
CGMutablePathRef p = CGPathCreateMutable();
CGPathAddRoundedRect(p, nil, cr, r->rounding, r->rounding);
CGPathCloseSubpath(p);
CGContextBeginPath(context);
CGContextAddPath(context, p);
CGContextDrawPath(context, kCGPathFill);
CGPathRelease(p);
}
} break;
case ZR_COMMAND_CIRCLE:
{
const struct zr_command_circle* c = zr_command(circle, cmd);
CGRect cr = CGRectMake(c->x, c->y, c->w, c->h);
setColor(c);
CGContextFillEllipseInRect(context, cr);
} break;
case ZR_COMMAND_TRIANGLE:
{
const struct zr_command_triangle* t = zr_command(triangle, cmd);
setColor(t);
CGContextBeginPath(context);
CGContextMoveToPoint (context, t->a.x, t->a.y);
CGContextAddLineToPoint(context, t->b.x, t->b.y);
CGContextAddLineToPoint(context, t->c.x, t->c.y);
CGContextClosePath(context);
CGContextFillPath(context);
} break;
case ZR_COMMAND_TEXT:
{
const struct zr_command_text* t = zr_command(text, cmd);
CGRect cr = CGRectMake(t->x, t->y, t->w, t->h);
CGContextSetRGBFillColor(context, t->background.r / 255.0, t->background.g / 255.0, t->background.b / 255.0, t->background.a / 255.0);
CGContextFillRect(context, cr);
NSString* aString = stringFromZR(t->string, t->length);
UIColor* fg = [UIColor colorWithRed: t->foreground.r / 255.0 green: t->foreground.g / 255.0 blue: t->foreground.b / 255.0 alpha: t->foreground.a / 255.0];
UIColor* bg = [UIColor colorWithRed: t->background.r / 255.0 green: t->background.g / 255.0 blue: t->background.b / 255.0 alpha: t->background.a / 255.0];
NSDictionary* attributes = @{ NSFontAttributeName: font, NSForegroundColorAttributeName: fg, NSBackgroundColorAttributeName: bg };
CGSize size = [aString sizeWithAttributes: attributes];
CGRect xr = CGRectMake(cr.origin.x, cr.origin.y + (cr.size.height - size.height) / 2.0, cr.size.width, size.height);
[aString drawInRect: xr withAttributes: attributes];
} break;
case ZR_COMMAND_CURVE:
case ZR_COMMAND_IMAGE:
case ZR_COMMAND_ARC:
case ZR_COMMAND_NOP:
default:
break;
}
}
UIGraphicsPopContext();
}
- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
{
UITouch* touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView: self];
zr_input_begin(&gui.ctx);
zr_input_motion(&gui.ctx, location.x, location.y);
zr_input_end(&gui.ctx);
zr_clear(&gui.ctx);
zr_input_begin(&gui.ctx);
zr_input_button(&gui.ctx, ZR_BUTTON_LEFT, location.x, location.y, zr_true);
zr_input_end(&gui.ctx);
run_demo(&gui);
[self setNeedsDisplay];
}
- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event
{
UITouch* touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView: self];
zr_clear(&gui.ctx);
zr_input_begin(&gui.ctx);
zr_input_motion(&gui.ctx, location.x, location.y);
zr_input_end(&gui.ctx);
run_demo(&gui);
[self setNeedsDisplay];
}
- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
{
UITouch* touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView: self];
zr_clear(&gui.ctx);
zr_input_begin(&gui.ctx);
zr_input_motion(&gui.ctx, location.x, location.y);
zr_input_button(&gui.ctx, ZR_BUTTON_LEFT, location.x, location.y, zr_false);
zr_input_end(&gui.ctx);
run_demo(&gui);
zr_clear(&gui.ctx);
zr_input_begin(&gui.ctx);
zr_input_motion(&gui.ctx, 0, 0);
zr_input_end(&gui.ctx);
run_demo(&gui);
[self setNeedsDisplay];
}
- (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event
{
[self touchesEnded: touches withEvent: event];
}
@end
#pragma mark - ViewController -
@interface ViewController : UIViewController
@property (strong, nonatomic) ZRView* zrView;
@end
@implementation ViewController
- (void) viewDidLoad
{
[super viewDidLoad];
_zrView = [[ZRView alloc] initWithFrame: self.view.bounds];
[self.view addSubview: _zrView];
}
@end
#pragma mark - App Delegate -
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow* window;
@property (strong, nonatomic) ViewController* viewController;
@end
@implementation AppDelegate
- (BOOL) application: (UIApplication*) application didFinishLaunchingWithOptions: (NSDictionary*) launchOptions
{
_window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
_viewController = [ViewController new];
_window.rootViewController = _viewController;
[_window makeKeyAndVisible];
return YES;
}
@end
int main(int argc, char* argv[])
{
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}