閲嶅啓shouldAutorateToInterfaceOrientation:錛岄檺鍒舵煇涓柟鍚?/span>浼氭敼鍙樺師鐐圭殑浣嶇疆錛屽師鐐逛細涓鐩翠繚鎸佸湪宸︿笂瑙掞紝浣嗗凡緇忎笉鏄師鏉ョ殑宸︿笂瑙掍簡
setStatusBarOrientation.鏀瑰彉鐘舵佹爮鐨勬柟鍚戙傚畠涓嶄細鏀瑰彉鍘熺偣鐨勪綅緗紝浣嗕細鏀瑰彉閿洏鐨勬柟鍚?/span>
鏃嬭漿鍓?/span>self.myview鐨?/span>frame ={0,0,320,50}
CGAffineTransform at =CGAffineTransformMakeRotation(M_PI/2);
[self.myview setTransform:at];
鏃嬭漿鍚?/span>frame={135,-135,50,320},瑙嗗浘鐨勬墍鏈夊儚绱犳棆杞?/span>90搴?/span>
鍧愭爣鏄浉瀵逛簬鐖惰鍥劇殑
鍋囧view宸茬粡杞垚绔栫殑錛岃繖鏃墮氳繃璁劇疆frame鑰屼笉鏄氳繃setTransform寮哄埗鎴愭í鐨勮瘽錛屼細鎴帀閮ㄥ垎鍥懼儚
鍧愭爣澶氭鍙樻崲鐨勫悎鎴愶紝瑕佷互琚彉鎹㈢殑view鐨勫眬閮ㄥ潗鏍囩郴涓哄弬鐓э紝姣斿
姝ゆ椂鐨?/span> frame ={135,65,50,320},鍙互鐪嬪埌瀹介珮宸茬粡鍙嶈繃鏉ヤ簡錛?/span>view涓殑鍍忕礌鏂瑰悜涔熸敼鍙樹簡錛岃屽鏋滃彧鏄敤setFrame鏉ユ敼鍙樺楂樼殑璇濇槸涓嶄細鏀瑰彉鍍忕礌鏂瑰悜鐨?/span>
Recently, I had need to provide a back button similar to the one used in Mobile Safari for a consulting project.
Many of the buttons used in the built-in iPhone applications are made available via the SDK with built in button types and graphics. Unfortunately, the back button is not one of these.
Because I needed to display the toolbar button from inside a static library which can not include images, I had to render the back arrow directly in code.
Since this was a bit time consuming, I thought I would share in hopes that it saves someone else a little bit of time.
- (CGContextRef)createContext { // create the bitmap context CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(nil,27,27,8,0, colorSpace,kCGImageAlphaPremultipliedLast); CFRelease(colorSpace); return context; } - (CGImageRef)createBackArrowImageRef { CGContextRef context = [self createContext]; // set the fill color CGColorRef fillColor = [[UIColor blackColor] CGColor]; CGContextSetFillColor(context, CGColorGetComponents(fillColor)); CGContextBeginPath(context); CGContextMoveToPoint(context, 8.0f, 13.0f); CGContextAddLineToPoint(context, 24.0f, 4.0f); CGContextAddLineToPoint(context, 24.0f, 22.0f); CGContextClosePath(context); CGContextFillPath(context); // convert the context into a CGImageRef CGImageRef image = CGBitmapContextCreateImage(context); CGContextRelease(context); return image; } - (UIBarButtonItem *)backButton { CGImageRef theCGImage = [self createBackArrowImageRef]; UIImage *backImage = [[UIImage alloc] initWithCGImage:theCGImage]; CGImageRelease(theCGImage); UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:backImage style:UIBarButtonItemStylePlain target:self.webView action:@selector(goBack)]; [backImage release], backImage = nil; return [backButton autorelease]; }