Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

anni.saini

macrumors newbie
Original poster
Jul 15, 2009
18
0
I have created Rect on NSScrollView, at present its position is Top-Left on the scroll view
--Figure 1 below

I want to shift it to Top-Center like this
--Figure 2 below

Can anybody help me on this...
how to do that?

regards,
Anni
 

Attachments

  • image.JPG
    image.JPG
    5.3 KB · Views: 803
What do you mean "on NSScrollView"? NSScrollViews usually contain a document view which is the main body of the scroll view that gets scrolled. In this view you would draw what you want horizontally centered.

Have a look at the Scroll View Programming Guide.
 
hi kainjow,

What do you mean "on NSScrollView"?

I forgot to mention, I mean NSView is added as a sub view on the NSScrollView.
If you could show me small code snippet for this that would be great... :)

thanks for reply.
 
I still don't understand how you want this setup. Is this view floating outside of the document view and anchored to the top of the scroll view? Or does it scroll just like your document view? Those are two very different setups.
 
If you want it fixed in place, I would try something like this:

NSRect viewFrame = [[theScollView contentView] frame];

to get the interior size of the view, then set the corner of the rectangle like this:

theRectangle.origin.x = ( ( viewFrame.size.width - theRectangle.size.width ) / 2.0 ) + viewFrame.origin.x;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.