cocoa

Subclass NSProgressIndicator

让人想犯罪 __ 提交于 2020-01-13 11:05:29
问题 i like to subclass a NSProgressIndicator. I've used this code and i set the Subclass in the Interface Builder: - (void)drawRect:(NSRect)dirtyRect { NSRect rect = NSInsetRect([self bounds], 1.0, 1.0); CGFloat radius = rect.size.height / 2; NSBezierPath *bz = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; [bz setLineWidth:2.0]; [[NSColor blackColor] set]; [bz stroke]; rect = NSInsetRect(rect, 2.0, 2.0); radius = rect.size.height / 2; bz = [NSBezierPath

Subclass NSProgressIndicator

廉价感情. 提交于 2020-01-13 11:04:57
问题 i like to subclass a NSProgressIndicator. I've used this code and i set the Subclass in the Interface Builder: - (void)drawRect:(NSRect)dirtyRect { NSRect rect = NSInsetRect([self bounds], 1.0, 1.0); CGFloat radius = rect.size.height / 2; NSBezierPath *bz = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; [bz setLineWidth:2.0]; [[NSColor blackColor] set]; [bz stroke]; rect = NSInsetRect(rect, 2.0, 2.0); radius = rect.size.height / 2; bz = [NSBezierPath

Subclass NSProgressIndicator

℡╲_俬逩灬. 提交于 2020-01-13 11:04:57
问题 i like to subclass a NSProgressIndicator. I've used this code and i set the Subclass in the Interface Builder: - (void)drawRect:(NSRect)dirtyRect { NSRect rect = NSInsetRect([self bounds], 1.0, 1.0); CGFloat radius = rect.size.height / 2; NSBezierPath *bz = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; [bz setLineWidth:2.0]; [[NSColor blackColor] set]; [bz stroke]; rect = NSInsetRect(rect, 2.0, 2.0); radius = rect.size.height / 2; bz = [NSBezierPath

How to set the font of NSMenu/NSMenuItems?

末鹿安然 提交于 2020-01-13 10:47:10
问题 I can’t figure out how to set the font/styling of my NSMenuItems in my NSMenu. I tried the setFont method on the NSMenu but it doesn’t seem to have any effect on the menu items. NSMenuItem doesn’t seem to have a setFont method. I would like for them all to have the same font/style so I would hope there’s just one property I can set somewhere. 回答1: They can have an attributed title, so you can set an attributed string as title with all it's attributed, font included: NSMutableAttributedString*

Mouse Events Bleeding Through NSView

守給你的承諾、 提交于 2020-01-13 09:57:07
问题 I have an NSView which covers its parent window's content view. This view has a click event handler which removes it from the content view. Inside this view, I have another view. When I drag the mouse in this inner view, the mouse events are applied not only to the view in the front, but also to the views behind. Additionally, the cursors from the views behind are showing up as well. This is the same problem occurring here: NSView overlay passes mouse events to underlying subviews? but the

Mouse Events Bleeding Through NSView

▼魔方 西西 提交于 2020-01-13 09:57:06
问题 I have an NSView which covers its parent window's content view. This view has a click event handler which removes it from the content view. Inside this view, I have another view. When I drag the mouse in this inner view, the mouse events are applied not only to the view in the front, but also to the views behind. Additionally, the cursors from the views behind are showing up as well. This is the same problem occurring here: NSView overlay passes mouse events to underlying subviews? but the

Objective-C Plugin Architecture Security (Mac, not iPhone)

自作多情 提交于 2020-01-13 09:29:17
问题 I'm possibly writing a plugin system for a Cocoa application (Mac, not iPhone). A common approach is the make each plugin a bundle, then inject the bundle into the main application. I'm concerned with the security implications of doing this, as the bundle will have complete access to the Objective-C runtime. I am especially concerned with a plugin having access to the code that handles registration and serial keys. Another plugin system we are considering is based on distributed notifications

How to clip larger images to fit into tabBar icons in tabBarController built programmatically.

妖精的绣舞 提交于 2020-01-13 08:58:30
问题 I have created a tab controller programmatically. Now, I wanted to add images to the different tabs, for which I used : self.tabBarItem.image = [UIImage imageNamed:@"Sample_Image.png"]; The problem is Sample_image is larger in size than is required by tab. So just want to know how can I clip the image to fit into tabs. 回答1: Sample_image is larger in size than is required by tab. Try this piece of code as this will resize the required image and return an UIImage instance with 30x30 size (size

Force keeping app window on top - Mac OS X

谁说我不能喝 提交于 2020-01-13 08:42:07
问题 Earlier i used Afloat for this but now it seems to be dead... Is there any alive software or any simple "handy" way to force keeping app window on top over others (including fullscreen apps) I can imagine this can be done with adding something to plist files inside .app like <!-- Info.plist --> <key>LSUIElement</key> <true /> for showing app over any fullscreen app (with keystroke) Google didn't help me much ( 回答1: Set the level of your mainWindow as [_window setLevel:NSModalPanelWindowLevel]

Howto “sandbox” my Lion application?

一笑奈何 提交于 2020-01-13 08:32:10
问题 Apple has decreed that all applications submitted to the Mac App Store must be sandboxed, starting in November. Ok, but how can I "sandbox" my app? I found the official Apple's guide Code Signing And Application Sandboxing Guide. This document lists the following steps: 1) "Enable sandboxing for your application." Ok, easy: I have to open Xcode 4, select the project, select the target, go to the Summary tab and check: "Enable Entitlements" "Enable App Sandboxing" ...and every single