How to add comment box to page? - objective-c

I am trying to model my "add comment" interface with what you see in the diagram below. However, I was unable to find such a UI element in the XCode library.
Is this a customized UI element? Or can I find a UI with the same look and feel as what you see in the diagram?

You can approximate it using a UIImageView (the silver gray background) and a UITextView on top of it which has a proper cornerRadius set. You'll need to:
#import <QuartzCore/QuartzCore.h>
in order to be able to set the cornerRadius property of the UITextView like this:
textView.layer.cornerRadius = 1.0f; // play around to see what gives you the above rounded effect to your needs.

Assuming you just want the textfield shape, you can use a UIImageView as background and have a textfield or textview on top of it accordingly...Now if you want that textview to expand thats another story, you can use strechableImageWithleftCapWidth: method on the image in order to be able to strech and expand it, and then you would need to create a custom UITextView class that expands as characters are typed in...

Related

How to make NSToolbar label move with it's Icon when both of them are visible

My app has an NSToolbar with a horizontal NSSplitView below it. An NSSegmentedControl in the toolbar moves with the splitview's divider, just like the one in OS X's Finder. NSLayoutGuide was used to align the two "views" from different storyboard "scenes". I shared this approach in this related question.
However, I don't know how to move the label with the icon. I've set the minSize and maxSize, but the label is fixed. In the first screenshot below, the "View Mode" label is not right below the segmented control.
It will be easy to add constrains to the label if I can access it. But I haven't found the API in NSToolbarItem, which only has a public view property. I've examine the view's hierarchy (the second screenshot), but I don't think I should use the variables with the _ prefix.
A related but different question is here. That question doesn't take moving into account.
You could try subclassing the NSToolbar setting the title to #"" and then creating your own UILabel and adding it as a subview? then you could reference it's property name and move it wherever you like

How to set an image to a NSButton to be resized along with the button?

I have an image (3width x 15height, the first and last pixels are rounded on the corners), and I want to create a button (the height of the button is always the same, 15px, but the width changes) that uses this image no matter what size it is, kinda like UIEdgeInsets on iOS.
I've tried to use [[button cell] setImageScaling:NSImageScaleAxesIndependently]; but the image gets distorted and loses quality.
How can I do this on OSX? Thanks!
You could probably create a custom subclass of NSButtonCell and use the Application Kit's NSDrawThreePartImage() function in the cell's drawInteriorWithFrame:inView: method.
For more info on how to use NSDrawThreePartImage(), see Cocoa Drawing Guide: Drawing Resizable Textures Using Images.
If it's possible to set this in graphical interface > Attribute Inspection > Button section Background

UIButton border along rounded rect

I have a button and its type is UIButtonTypeRoundedRect, but its border does not go along the rounded corner. How can I curve the border.
Check out this blog post I recently wrote: UI Polish in An Instant
You're on the right track accessing the button's layer property, but there is more you need to do (for example, to get rounded corners, add deleteButton1.layer.cornerRadius = 10), and more you can do, all without extra images.
Images are the recommended method for creating custom buttons. Apple's built-in buttons are basically only there for prototyping.
You could also create a subclass of UIButton and then override the methods for drawInRect and provide custom drawing code, probably using CoreGraphics. However, it is still much cleaner in code and more efficient at runtime to just use images.

Question about these UIButtons

How can I get a UIButton like the ones at the bottom of this picutre (move and delete)? Specifically, I want an image with a text just like that. http://4.bp.blogspot.com/_QLwms0mVa4w/SQN0MqPIpXI/AAAAAAAAAA8/lEikKn9eP_0/s1600-h/Screenshot+2008-10-25+15:31:21+-0400-1.png
Thanks.
For Jason:
The image sticks right beside the label. Is there anyway from IB I can set it to align to the left, while the label aligns to the right? Here's what it looks like right now:
What you can do is in Interface Builder, the UIButton can be set to a type of "Custom"
After you have done this, you can simply use your own image for the button and different images for each state of the button.
Although with this approach you won't be able to have additional text modified on it like the mail app has with "Delete (1)". However, if you don't need that then this solution will work for you.
Alternatively, if you just want an image stuck onto your existing button then there is an Image property in Interface Builder where you can slap on an image to your button.
If you need more functionality then you would probably have to create your own UIButton by subclassing to handle it.

Assigning a Background image to CGRect Object!

I am new to iphone Programming . I have a rectangle on which i display some data. I want to assign an image to its background. And is it possible that the data would be visible even after the image is assigned . Any idea how i can do it ?
Thanks
You don't say how you are displaying your data, so it isn't possible to respond properly.
But in general, you create simple displays using Interface Builder, and can position a UILabel over a UIImageView, and can set the labels background to be transparent.
If you are drawing using drawRect:, then you probably shouldn't be. And yes, you can draw text over an image doing it this way, too.
CGRect is just a structure representing an abstract rectangle. You do not associate styling information (e.g. color, background image, etc.) to it because this does not make sense.
If you simply want to display an image on a window, drag the PNG image into your project, then you can find your image in Interface Builder, which can be put onto the window.