I lack experience in the iPhone SDK and Objective-C, but I was hoping you guys could help me understanda thing or two so I could develop applications in a language I'm more comfortable with (Python).
I wanted to give one of my controls a color, so I looked on this forum to see how it would be done and found:
Code:
[label setText:@"Hello World"];
[label setTextColor:[UIColor blueColor]];
Now, I was hoping it would be as simple as control.setTextColor_(UIColor.blueColor) but my application just crashes (still haven't figured out a way to print or log errors).
Does anyone know where I could find blueColor, or, alternatively how to build my own color?
Other than the HelloWorld app (which I used religiously) there's no resources or information I can find on the net on iphone/python. So because of that I'll post my demo program, in case it'll help any future developers who check forum following the same goal.
Code:
import sys
import objc
from _uicaboodle import UIApplicationMain
from objc import YES, NO, NULL
objc.loadBundle('UIKit', globals(), '/System/Library/Frameworks/UIKit.framework')
class Application(UIApplication):
@objc.signature('v@:@')
def applicationDidFinishLaunching_(self, unused):
# Initialize the window and view.
self.window = UIWindow.alloc().initWithFrame_(UIHardware.fullScreenApplicationContentRect())
self.view = UIView.alloc().initWithFrame_(self.window.bounds())
# Create the navigation bar
self.navbar = UINavigationBar.alloc().initWithFrame_(((0, 0), UINavigationBar.defaultSize()))
self.navbar.setBarStyle_(1)
self.view.addSubview_(self.navbar)
# Create and add the navigation bar
self.navbar.pushNavigationItem_(UINavigationItem.alloc().initWithTitle_('iChatters'))
navbar_height = self.navbar.bounds()[0][1] + self.navbar.bounds()[1][1]
# Create a textview
self.textview = UITextView.alloc().initWithFrame_(((4, navbar_height + 4), (100, 24)))
#self.textview.setText_(UIColor.blueColor_)
self.view.addSubview_(self.textview)
# Create a button!
self.button = UIThreePartButton.alloc().initWithFrame_(((4 + 50, navbar_height + 4 + 50), (100, 24)))
self.button.setTitle_('CLICK ME')
self.button.setShowPressFeedback_(YES)
self.button.setEnabled_(YES)
self.view.addSubview_(self.button)
# Setup the window
self.window.orderFront_(self)
self.window.makeKey_(self)
self.window._setHidden_(NO)
self.window.setContentView_(self.view)
UIApplicationMain(sys.argv, Application)