I'm struggling with an NSTextField background issue. The textfield is within a custom view that has a semi-transparent black background. I've tried subclassing the field, the field's cell and a few other things to no avail. I'm getting this clearColor background outside of the text field cell. I'm looking for basically just a black NSSearchFeld, not having much luck though.
here is what i'm getting
I basically just want a textfield with a rounded stroke which blends into the black background.
thanks all, i'm fairly new to Xdev
figured it out, I needed to have the custom NSView subclass I'm using to draw the window use
[self bounds] when drawing vs the dirtyRect passed to the drawrect method.
Related
I am working on creating a color picker for "iOS". I am using this project, since it does what i want: "This"
I want to create a moveable circle (UIView) on top of the palette (UIImageView).
What I want to do is, while users move the circle, take the touch point and call the method getPixelColorAtLocation(); and change the background color of the circle to the color on current point. (Seen on most of the color palette/wheels)
The method getPixelColorAtLocation() is available on a child view. I created a circle with UIView on parent view, the problem is I cant call to getPixelColorAtLocation() from parent view.
My question is, Is there anyway to add a UIView as a subView to UIImageView. If I cant, what choices do I have to achieve what I want?
Yes you can do this.
[myImageView addSubview:sampleView];
An image view is just a subclass of UIView, so you can add subviews to it however you'd like. If there's a reason why you can't do so, then you can always make it a subview of the image view's superview, move it to the front, and then use convertPoint:toView: to convert to the image view's coordinate system, then get the pixel color.
I have a NSView inside a NSWindow and the background of NSWindow is set to black (with alpha of 0.7). Is there anyway to have the NSView showing what's underneath the NSWindow? In other words, how do I make the part where NSWindow and NSView overlap to have clear background?
Thanks!
You can try the setOpaque method
If I understand properly, it seems like you're trying to have a window with hole in it. You can take a look at apple's sample code Round Transparent Window. It shows how to add transparent areas to an NSWindow.
I have a UIViewController that initially is of a white background and allows the user to color in the UIImageView of a certain color by touch events. When all is done, I would like a way to highlight or show the uncolored areas (the remaining white areas) of the UIImageView. Is there a nice way to implement this. I have tried messing with CGBitMap methods but I have not been successful without any errors in code.
Thanks!
Could you simply change the background color of your UIViewController?
This question already has an answer here:
Holes in NSView or NSWindow
(1 answer)
Closed 6 years ago.
I want to have a more or less standard NSWindow with a toolbar and all that, but I want the content view to be transparent so that I can see through it. At the same time I want to keep the light gray outline of the window and also it's shadow. BUT I want to avoid the "inner" shadow I get from the toolbar inside the content view area.
What I have tried so far is just to set the window background color to a semi transparent color and also set opaque to NO. The problem is that the window border fades away with the alpha of the background itself, and the more transparency I have on the background, the more the shadow of the toolbar shows up within the content view.
Generally, the window shadow and border changes depending on the transparency of the content view, which I totally understand. But I want a behavior where it keeps the border and shadow just as if it was a completely opaque window, and then I want the content view area to be transparent.
I am not sure what I need to do conceptually to make it work. Maybe I have to draw the window border myself, maybe not. Maybe I need to draw the shadow myself, or maybe not.
Is there anyone that know how to build this? I don't need exact code details, but rather what parts I need to do custom..
I appreciate any input!
I dont't know if this is of any value for you after all this time but try:
[aWindow setOpaque:NO];
[aWindow setBackgroundColor:[NSColor clearColor]];
Subclass the NSView class, override the drawRect:(NSRect)dirtyRect method and set the color of the view as clearcolor, now set the class of your content view as the Subclass of NSView.
I'm reading pixels from an area of the main screen via NSOpenGLContext. Now I would like to draw a rect around that area to indicate where it actually is.
How would I do this?
My first thought was the "Cocoa way": create a transparent fullscreen NSWindow and a custom NSView to draw the rectangle path. But that feels a bit too complicated. Isn't it possible to draw directly on the NSOpenGLContext?
If you want to draw over elements not inside your application the floating window is the only correct way. There’s really no complication except mapping positions properly, which is easy to do with the coordinate-space conversions available on NSView and NSWindow.