Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:02:53+00:00 2026-06-14T19:02:53+00:00

I have used IB to do that,and everything is okay,but when I wrote code

  • 0

I have used IB to do that,and everything is okay,but when I wrote code to do that I don’t know,
how to get the same result with IB.

In IB, I set it like the screenshot, the image I set will has same size in the button but when I use code, the image only show a part that to said,
when I use IB to set,the image will stretch automatically but using code to do that,it is not stretch.

Could anyone find the difference between code and IB screenshot?

1) write code to create NSButton is like this:

NSButton *tempBtn = [[NSButton alloc] initWithFrame: NSMakeRect(200, 200, 20, 20)];
[tempBtn setButtonType: NSMomentaryPushInButton];
[tempBtn setBezelStyle: NSRoundedDisclosureBezelStyle];
[tempBtn setBordered: NO];
[tempBtn setImage: [NSImage imageNamed: @"Basketball"]];
[tempBtn setImagePosition: NSImageOnly];
[tempBtn setTarget: self];
[tempBtn setAction: @selector(clickBtn:)];
[self.window.contentView addSubview: tempBtn];
[tempBtn release];

2) set it in IB is like this:
set in IB

the result is like this:

result screenshot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:02:54+00:00Added an answer on June 14, 2026 at 7:02 pm

    You shoud set the imageScaling of the cell related to the button:

    [tempBtn.cell setImageScaling:NSImageScaleProportionallyDown];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used a plugin that uses prototype js, it's working fine but the
Yes, I know that my problem is not the unique, but I have analysed
Okay I have something that looks like this: Company Name-1234 I only want the
What libs have you used for that? How compatible are they with one another?
I have used a list view that uses a grid view in WPF. I
I have used FlipView from Metro Applications and that's what I'm trying to looking
I have used my local iis to test the site and now that its
I have used TableCellRenderers on a table to repaint cells so that every alternate
I have used DLL Export viewer to try and find the functions that are
I have a function that I have used a bunch of times in various

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.