{"id":1310,"date":"2012-07-04T07:48:37","date_gmt":"2012-07-04T14:48:37","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=1310"},"modified":"2012-07-04T07:48:37","modified_gmt":"2012-07-04T14:48:37","slug":"xcode-buttons","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=1310","title":{"rendered":"Xcode Buttons"},"content":{"rendered":"<p>This is some code I used to put a reset button on the screen. It\u2019s mostly self-documenting. First, create a rect. I\u2019ve already defined the x and y coordinates\u2014buttonX and distanceFromTop based on the screen width and other buttons on the screen. Likewise, I\u2019ve already defined the width. The rest of the code is just assigning properties to the button. The action is a method in the file that changes the image to a &#8216;Selected&#8217; image.<\/p>\n<p><pre><code class=\"\u2019smaller\u2019 preserve-code-formatting\">\n\/\/ Reset Button\n&nbsp;&nbsp;&nbsp;&nbsp;@synthesize resetButton = resetButton;\n&nbsp;&nbsp;&nbsp;&nbsp;....\n\n&nbsp;&nbsp;&nbsp;&nbsp;CGRect resetButtonFrame = CGRectMake(buttonX, distanceFromTop,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; button_width, 25.0f);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;self.resetButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];\n&nbsp;&nbsp;&nbsp;&nbsp;self.resetButton.titleLabel.font&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= [UIFont systemFontOfSize: 16];\n&nbsp;&nbsp;&nbsp;&nbsp;self.resetButton.titleLabel.textColor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = [UIColor blueColor];\n&nbsp;&nbsp;&nbsp;&nbsp;self.resetButton.titleLabel.shadowOffset&nbsp;&nbsp;&nbsp;&nbsp;= CGSizeMake (1.0, 0.0);\n&nbsp;&nbsp;&nbsp;&nbsp;[self.resetButton setTitle:@&quot;Reset Scoring&quot; forState:UIControlStateNormal];\n&nbsp;&nbsp;&nbsp;&nbsp;[self.resetButton setFrame:resetButtonFrame];\n&nbsp;&nbsp;&nbsp;&nbsp;[self.resetButton addTarget:self \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; action:@selector(resetScorekeeper:) \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; forControlEvents:UIControlEventTouchUpInside];\n&nbsp;&nbsp;&nbsp;&nbsp;[self.view addSubview:self.resetButton];\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/ This line makes the icons stay in the center of the screen when you rotate\n&nbsp;&nbsp;&nbsp;&nbsp;self.resetButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;....\n\n- (IBAction)resetScorekeeper:(UIButton *)sender {\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;[self resetResultsFile];\n&nbsp;&nbsp;&nbsp;&nbsp;[sender setImage:[UIImage imageNamed:@&quot;ResetScoringSelected.png&quot;] forState:UIControlStateNormal];\n}\n<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is some code I used to put a reset button on the screen. It\u2019s mostly self-documenting. First, create a rect. I\u2019ve already defined the x and y coordinates\u2014buttonX and distanceFromTop based on the screen width and other buttons on the screen. Likewise, I\u2019ve already defined the width. The rest of the code is just &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=1310\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Xcode Buttons<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1310","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/1310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1310"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/1310\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}